FileIO::Read() 的实现

the implementation of FileIO::Read()

当我阅读 fileIO::read() 的源代码时,我遇到了一个问题。 首先,fileIO::Read()的源码是:

enter int32_t FileIO::Read(int64_t offset,
                 char* buffer,
                 int32_t bytes_to_read,
                 const CompletionCallback& cc)
  {
    if (has_interface<PPB_FileIO_1_1>()) {
      return get_interface<PPB_FileIO_1_1>()->Read(pp_resource(),
          offset, buffer, bytes_to_read, cc.pp_completion_callback());
   } else if (has_interface<PPB_FileIO_1_0>()) {
      return get_interface<PPB_FileIO_1_0>()->Read(pp_resource(),
    offset, buffer, bytes_to_read, cc.pp_completion_callback());
  }
  return cc.MayForce(PP_ERROR_NOINTERFACE);
}

我们可以看到跨越get_interface(),我们得到一个Func Pointer.the问题是,如何得到这个指针。 然后我找到 get_interface:

的源代码
template <typename T> inline T const* get_interface() {
  static T const* funcs = reinterpret_cast<T const*>(
  pp::Module::Get()->GetBrowserInterface(interface_name<T>()));
  return funcs;
}

然后是GetBrowserInterface()的源码,

const void* Module::GetBrowserInterface(const char* interface_name) {
  return get_browser_interface_(interface_name);
}

Module::Module() : pp_module_(0), get_browser_interface_(NULL), core_(NULL){}

我们可以看到,在构建模块时,我们将get_browser_interface_设置为NULL,我发现没有任何地方没有调用InternalInit() Func。 所以它混淆了如何获得 Read() Pointer.And Read() 实现的源代码在哪里?谢谢。

pp::Module::InternalInitppp_entrypoints.cc 中调用。当您在 ppapi_cpp 库中 link 时,此文件中的函数将作为 PPAPI Native Client 模块的入口点调用。

具体来说,PPP_InitializeModule 被模块加载器调用以初始化 Native Client 模块。

PPB_FileIO_1_1::Read的源代码可以在ppapi库here. This forwards to the proxy here中找到。