summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-18 22:31:09 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-18 22:31:09 +0000
commitd259a8ecab95cd657b9c7d413e8bfa3c86d0d4cb (patch)
tree83805324a9ffeeb10b334d544b13155c8c52b069 /content/browser
parent772b57ab0dcd7843157b961f10999e48088e8973 (diff)
downloadchromium_src-d259a8ecab95cd657b9c7d413e8bfa3c86d0d4cb.zip
chromium_src-d259a8ecab95cd657b9c7d413e8bfa3c86d0d4cb.tar.gz
chromium_src-d259a8ecab95cd657b9c7d413e8bfa3c86d0d4cb.tar.bz2
Support getting the font list in Pepper. This currently only works out of
process. This adds a function to the font interface to get the font list. Since we don't have arrays or dictionaries in Pepper yet, I used a string with nulls separating the names. A previous attempt to make a "font list resource" proved excessively complicated and not actually much easier for clients to deal with. This refactors the existing font list getting that used to be in the options for the browser. I moved it to content and split it into two pieces, the synchronous version, and then an asynchronous wrapper around that which both the prefs code and the pepper code use. This cleaned up some of the preferences code, and also fixes the leak of the entire font list in the code. I used the new callback/bind system for the async font loading. I had to add BrowserThread support for the new system. This uses the PepperMessageFilter to listen for font load requests from the plugin in the browser process. This is nice because we can add stuff here and have messages serviced for both in-process and out-of-process plugins. This proved to be complicated due to the HostResolver used in some of the existing code, and thread restrictions for how to deal with it. This is why there are two modes for the filter object. I changed the delegates around for the Dispatcher. Now the PluginDispatcher has the delegate interface since the HostDispatcher didn't actually need any of them and we were accumulating a lot of empty functions in the PepperPluginRegistry. It's possible for the fonts to be loaded on Windows and Mac without IPC, since enumerating fonts should be possible inside the sandbox. I didn't implement this since it adds extra complexity and probably doesn't give that much benefit. TEST=manual BUG=none Review URL: http://codereview.chromium.org/7044012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85827 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
-rw-r--r--content/browser/browser_thread.cc70
-rw-r--r--content/browser/browser_thread.h32
-rw-r--r--content/browser/font_list_async.cc51
-rw-r--r--content/browser/font_list_async.h42
-rw-r--r--content/browser/plugin_service.cc10
-rw-r--r--content/browser/plugin_service.h3
-rw-r--r--content/browser/ppapi_plugin_process_host.cc6
-rw-r--r--content/browser/ppapi_plugin_process_host.h19
-rw-r--r--content/browser/renderer_host/pepper_message_filter.cc57
-rw-r--r--content/browser/renderer_host/pepper_message_filter.h28
-rw-r--r--content/browser/renderer_host/render_message_filter.cc15
11 files changed, 316 insertions, 17 deletions
diff --git a/content/browser/browser_thread.cc b/content/browser/browser_thread.cc
index 47b7861..3809989 100644
--- a/content/browser/browser_thread.cc
+++ b/content/browser/browser_thread.cc
@@ -139,6 +139,38 @@ bool BrowserThread::IsMessageLoopValid(ID identifier) {
// static
bool BrowserThread::PostTask(ID identifier,
const tracked_objects::Location& from_here,
+ const base::Closure& task) {
+ return PostTaskHelper(identifier, from_here, task, 0, true);
+}
+
+// static
+bool BrowserThread::PostDelayedTask(ID identifier,
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ int64 delay_ms) {
+ return PostTaskHelper(identifier, from_here, task, delay_ms, true);
+}
+
+// static
+bool BrowserThread::PostNonNestableTask(
+ ID identifier,
+ const tracked_objects::Location& from_here,
+ const base::Closure& task) {
+ return PostTaskHelper(identifier, from_here, task, 0, false);
+}
+
+// static
+bool BrowserThread::PostNonNestableDelayedTask(
+ ID identifier,
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ int64 delay_ms) {
+ return PostTaskHelper(identifier, from_here, task, delay_ms, false);
+}
+
+// static
+bool BrowserThread::PostTask(ID identifier,
+ const tracked_objects::Location& from_here,
Task* task) {
return PostTaskHelper(identifier, from_here, task, 0, true);
}
@@ -236,3 +268,41 @@ bool BrowserThread::PostTaskHelper(
return !!message_loop;
}
+
+// static
+bool BrowserThread::PostTaskHelper(
+ ID identifier,
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ int64 delay_ms,
+ bool nestable) {
+ DCHECK(identifier >= 0 && identifier < ID_COUNT);
+ // Optimization: to avoid unnecessary locks, we listed the ID enumeration in
+ // order of lifetime. So no need to lock if we know that the other thread
+ // outlives this one.
+ // Note: since the array is so small, ok to loop instead of creating a map,
+ // which would require a lock because std::map isn't thread safe, defeating
+ // the whole purpose of this optimization.
+ ID current_thread;
+ bool guaranteed_to_outlive_target_thread =
+ GetCurrentThreadIdentifier(&current_thread) &&
+ current_thread >= identifier;
+
+ if (!guaranteed_to_outlive_target_thread)
+ lock_.Acquire();
+
+ MessageLoop* message_loop = browser_threads_[identifier] ?
+ browser_threads_[identifier]->message_loop() : NULL;
+ if (message_loop) {
+ if (nestable) {
+ message_loop->PostDelayedTask(from_here, task, delay_ms);
+ } else {
+ message_loop->PostNonNestableDelayedTask(from_here, task, delay_ms);
+ }
+ }
+
+ if (!guaranteed_to_outlive_target_thread)
+ lock_.Release();
+
+ return !!message_loop;
+}
diff --git a/content/browser/browser_thread.h b/content/browser/browser_thread.h
index 680c25a..c226551 100644
--- a/content/browser/browser_thread.h
+++ b/content/browser/browser_thread.h
@@ -6,13 +6,15 @@
#define CONTENT_BROWSER_BROWSER_THREAD_H_
#pragma once
-#if defined(UNIT_TEST)
-#include "base/logging.h"
-#endif // UNIT_TEST
+#include "base/callback.h"
#include "base/synchronization/lock.h"
#include "base/task.h"
#include "base/threading/thread.h"
+#if defined(UNIT_TEST)
+#include "base/logging.h"
+#endif // UNIT_TEST
+
namespace base {
class MessageLoopProxy;
}
@@ -105,6 +107,23 @@ class BrowserThread : public base::Thread {
// the target thread may already have a Quit message in its queue.
static bool PostTask(ID identifier,
const tracked_objects::Location& from_here,
+ const base::Closure& task);
+ static bool PostDelayedTask(ID identifier,
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ int64 delay_ms);
+ static bool PostNonNestableTask(ID identifier,
+ const tracked_objects::Location& from_here,
+ const base::Closure& task);
+ static bool PostNonNestableDelayedTask(
+ ID identifier,
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ int64 delay_ms);
+
+ // TODO(brettw) remove these when Task->Closure conversion is done.
+ static bool PostTask(ID identifier,
+ const tracked_objects::Location& from_here,
Task* task);
static bool PostDelayedTask(ID identifier,
const tracked_objects::Location& from_here,
@@ -203,12 +222,19 @@ class BrowserThread : public base::Thread {
// Common initialization code for the constructors.
void Initialize();
+ // TODO(brettw) remove this variant when Task->Closure migration is complete.
static bool PostTaskHelper(
ID identifier,
const tracked_objects::Location& from_here,
Task* task,
int64 delay_ms,
bool nestable);
+ static bool PostTaskHelper(
+ ID identifier,
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ int64 delay_ms,
+ bool nestable);
// The identifier of this thread. Only one thread can exist with a given
// identifier at a given time.
diff --git a/content/browser/font_list_async.cc b/content/browser/font_list_async.cc
new file mode 100644
index 0000000..f24001f
--- /dev/null
+++ b/content/browser/font_list_async.cc
@@ -0,0 +1,51 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/font_list_async.h"
+
+#include "base/bind.h"
+#include "base/values.h"
+#include "content/browser/browser_thread.h"
+#include "content/common/font_list.h"
+
+namespace content {
+
+namespace {
+
+// Just executes the given callback with the parameter.
+void ReturnFontListToOriginalThread(
+ const base::Callback<void(scoped_refptr<FontListResult>)>& callback,
+ scoped_refptr<FontListResult> result) {
+ callback.Run(result);
+}
+
+void GetFontListOnFileThread(
+ BrowserThread::ID calling_thread_id,
+ const base::Callback<void(scoped_refptr<FontListResult>)>& callback) {
+ scoped_refptr<FontListResult> result(new FontListResult);
+ result->list.reset(GetFontList_SlowBlocking());
+ BrowserThread::PostTask(calling_thread_id, FROM_HERE,
+ base::Bind(&ReturnFontListToOriginalThread, callback, result));
+}
+
+} // namespace
+
+FontListResult::FontListResult() {
+}
+
+FontListResult::~FontListResult() {
+}
+
+void GetFontListAsync(
+ const base::Callback<void(scoped_refptr<FontListResult>)>& callback) {
+ BrowserThread::ID id;
+ bool well_known_thread = BrowserThread::GetCurrentThreadIdentifier(&id);
+ DCHECK(well_known_thread)
+ << "Can only call GetFontList from a well-known thread.";
+
+ BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
+ base::Bind(&GetFontListOnFileThread, id, callback));
+}
+
+} // namespace content
diff --git a/content/browser/font_list_async.h b/content/browser/font_list_async.h
new file mode 100644
index 0000000..0c3e786
--- /dev/null
+++ b/content/browser/font_list_async.h
@@ -0,0 +1,42 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_FONT_LIST_ASYNC_H_
+#define CONTENT_BROWSER_FONT_LIST_ASYNC_H_
+
+#include "base/callback.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+
+class ListValue;
+
+namespace content {
+
+// Wraps ownership of a ListValue so we can send it across threads without
+// having ownership problems (for example if the calling thread goes away
+// before the callback is executed, we want the ListValue to be destroyed.
+struct FontListResult : public base::RefCountedThreadSafe<FontListResult> {
+ FontListResult();
+ ~FontListResult();
+
+ scoped_ptr<ListValue> list;
+};
+
+// Retrieves the list of fonts on the system as a list of strings. It provides
+// a non-blocking interface to GetFontList_SlowBlocking in common/.
+//
+// This function will run asynchronously on a background thread since getting
+// the font list from the system can be slow. This function may be called from
+// any thread that has a BrowserThread::ID. The callback will be executed on
+// the calling thread.
+//
+// If the caller wants to take ownership of the ListValue, it can just do
+// FontListResult.list.release() or use scoped_ptr.swap() because this value
+// isn't used for anything else.
+void GetFontListAsync(
+ const base::Callback<void(scoped_refptr<FontListResult>)>& callback);
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_FONT_LIST_ASYNC_H_
diff --git a/content/browser/plugin_service.cc b/content/browser/plugin_service.cc
index 6d69f19..f4c293f 100644
--- a/content/browser/plugin_service.cc
+++ b/content/browser/plugin_service.cc
@@ -21,6 +21,7 @@
#include "content/browser/ppapi_plugin_process_host.h"
#include "content/browser/renderer_host/render_process_host.h"
#include "content/browser/renderer_host/render_view_host.h"
+#include "content/browser/resource_context.h"
#include "content/common/notification_service.h"
#include "content/common/notification_type.h"
#include "content/common/pepper_plugin_registry.h"
@@ -239,7 +240,8 @@ PluginProcessHost* PluginService::FindOrStartNpapiPluginProcess(
}
PpapiPluginProcessHost* PluginService::FindOrStartPpapiPluginProcess(
- const FilePath& plugin_path) {
+ const FilePath& plugin_path,
+ PpapiPluginProcessHost::Client* client) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
PpapiPluginProcessHost* plugin_host = FindPpapiPluginProcess(plugin_path);
@@ -252,7 +254,8 @@ PpapiPluginProcessHost* PluginService::FindOrStartPpapiPluginProcess(
return NULL;
// This plugin isn't loaded by any plugin process, so create a new process.
- scoped_ptr<PpapiPluginProcessHost> new_host(new PpapiPluginProcessHost);
+ scoped_ptr<PpapiPluginProcessHost> new_host(new PpapiPluginProcessHost(
+ client->GetResourceContext()->host_resolver()));
if (!new_host->Init(*info)) {
NOTREACHED(); // Init is not expected to fail.
return NULL;
@@ -304,7 +307,8 @@ void PluginService::OpenChannelToNpapiPlugin(
void PluginService::OpenChannelToPpapiPlugin(
const FilePath& path,
PpapiPluginProcessHost::Client* client) {
- PpapiPluginProcessHost* plugin_host = FindOrStartPpapiPluginProcess(path);
+ PpapiPluginProcessHost* plugin_host = FindOrStartPpapiPluginProcess(
+ path, client);
if (plugin_host)
plugin_host->OpenChannelToPlugin(client);
else // Send error.
diff --git a/content/browser/plugin_service.h b/content/browser/plugin_service.h
index 1d8806b..2c8d115 100644
--- a/content/browser/plugin_service.h
+++ b/content/browser/plugin_service.h
@@ -73,7 +73,8 @@ class PluginService
PluginProcessHost* FindOrStartNpapiPluginProcess(
const FilePath& plugin_path);
PpapiPluginProcessHost* FindOrStartPpapiPluginProcess(
- const FilePath& plugin_path);
+ const FilePath& plugin_path,
+ PpapiPluginProcessHost::Client* client);
PpapiBrokerProcessHost* FindOrStartPpapiBrokerProcess(
const FilePath& plugin_path);
diff --git a/content/browser/ppapi_plugin_process_host.cc b/content/browser/ppapi_plugin_process_host.cc
index 73ab851..f5a8885 100644
--- a/content/browser/ppapi_plugin_process_host.cc
+++ b/content/browser/ppapi_plugin_process_host.cc
@@ -16,8 +16,10 @@
#include "ipc/ipc_switches.h"
#include "ppapi/proxy/ppapi_messages.h"
-PpapiPluginProcessHost::PpapiPluginProcessHost()
- : BrowserChildProcessHost(ChildProcessInfo::PPAPI_PLUGIN_PROCESS) {
+PpapiPluginProcessHost::PpapiPluginProcessHost(net::HostResolver* host_resolver)
+ : BrowserChildProcessHost(ChildProcessInfo::PPAPI_PLUGIN_PROCESS),
+ filter_(new PepperMessageFilter(host_resolver)) {
+ AddFilter(filter_.get());
}
PpapiPluginProcessHost::~PpapiPluginProcessHost() {
diff --git a/content/browser/ppapi_plugin_process_host.h b/content/browser/ppapi_plugin_process_host.h
index 0412c25..15667d4 100644
--- a/content/browser/ppapi_plugin_process_host.h
+++ b/content/browser/ppapi_plugin_process_host.h
@@ -10,10 +10,20 @@
#include "base/basictypes.h"
#include "base/file_path.h"
+#include "base/memory/ref_counted.h"
#include "content/browser/browser_child_process_host.h"
+#include "content/browser/renderer_host/pepper_message_filter.h"
struct PepperPluginInfo;
+namespace content {
+class ResourceContext;
+}
+
+namespace net {
+class HostResolver;
+}
+
class PpapiPluginProcessHost : public BrowserChildProcessHost {
public:
class Client {
@@ -28,10 +38,13 @@ class PpapiPluginProcessHost : public BrowserChildProcessHost {
// IPC::ChannelHandle()
virtual void OnChannelOpened(base::ProcessHandle plugin_process_handle,
const IPC::ChannelHandle& channel_handle) = 0;
+
+ // Returns the resource context for the renderer requesting the channel.
+ virtual const content::ResourceContext* GetResourceContext() = 0;
};
// You must call Init before doing anything else.
- PpapiPluginProcessHost();
+ PpapiPluginProcessHost(net::HostResolver* host_resolver);
virtual ~PpapiPluginProcessHost();
// Actually launches the process with the given plugin info. Returns true
@@ -47,7 +60,6 @@ class PpapiPluginProcessHost : public BrowserChildProcessHost {
// The client pointer must remain valid until its callback is issued.
private:
-
void RequestPluginChannel(Client* client);
virtual bool CanShutdown();
@@ -62,6 +74,9 @@ class PpapiPluginProcessHost : public BrowserChildProcessHost {
// IPC message handlers.
void OnRendererPluginChannelCreated(const IPC::ChannelHandle& handle);
+ // Handles most requests from the plugin.
+ scoped_refptr<PepperMessageFilter> filter_;
+
// Channel requests that we are waiting to send to the plugin process once
// the channel is opened.
std::vector<Client*> pending_requests_;
diff --git a/content/browser/renderer_host/pepper_message_filter.cc b/content/browser/renderer_host/pepper_message_filter.cc
index 19208ae..9381ed6 100644
--- a/content/browser/renderer_host/pepper_message_filter.cc
+++ b/content/browser/renderer_host/pepper_message_filter.cc
@@ -5,9 +5,12 @@
#include "content/browser/renderer_host/pepper_message_filter.h"
#include "base/basictypes.h"
+#include "base/bind.h"
#include "base/process_util.h"
#include "base/threading/worker_pool.h"
+#include "base/values.h"
#include "content/browser/browser_thread.h"
+#include "content/browser/font_list_async.h"
#include "content/browser/renderer_host/browser_render_process_host.h"
#include "content/browser/resource_context.h"
#include "content/common/pepper_messages.h"
@@ -17,6 +20,7 @@
#include "net/base/host_resolver.h"
#include "net/url_request/url_request_context.h"
#include "ppapi/c/private/ppb_flash_net_connector.h"
+#include "ppapi/proxy/ppapi_messages.h"
#include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h"
#if defined(ENABLE_FLAPPER_HACKS)
@@ -36,10 +40,17 @@ const PP_Flash_NetAddress kInvalidNetAddress = { 0 };
PepperMessageFilter::PepperMessageFilter(
const content::ResourceContext* resource_context)
- : resource_context_(resource_context) {
+ : resource_context_(resource_context),
+ host_resolver_(NULL) {
DCHECK(resource_context_);
}
+PepperMessageFilter::PepperMessageFilter(net::HostResolver* host_resolver)
+ : resource_context_(NULL),
+ host_resolver_(host_resolver) {
+ DCHECK(host_resolver);
+}
+
PepperMessageFilter::~PepperMessageFilter() {}
bool PepperMessageFilter::OnMessageReceived(const IPC::Message& msg,
@@ -52,6 +63,8 @@ bool PepperMessageFilter::OnMessageReceived(const IPC::Message& msg,
#endif // ENABLE_FLAPPER_HACKS
IPC_MESSAGE_HANDLER(PepperMsg_GetLocalTimeZoneOffset,
OnGetLocalTimeZoneOffset)
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(PpapiHostMsg_PPBFont_GetFontFamilies,
+ OnGetFontFamilies)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP_EX()
return handled;
@@ -178,7 +191,7 @@ void PepperMessageFilter::OnConnectTcp(int routing_id,
// The lookup request will delete itself on completion.
LookupRequest* lookup_request =
- new LookupRequest(this, resource_context_->host_resolver(),
+ new LookupRequest(this, GetHostResolver(),
routing_id, request_id, request_info);
lookup_request->Start();
}
@@ -295,3 +308,43 @@ void PepperMessageFilter::OnGetLocalTimeZoneOffset(base::Time t,
base::Time cur = base::Time::FromUTCExploded(exploded);
*result = (adj_time - cur).InSecondsF();
}
+
+void PepperMessageFilter::OnGetFontFamilies(IPC::Message* reply_msg) {
+ content::GetFontListAsync(
+ base::Bind(&PepperMessageFilter::GetFontFamiliesComplete,
+ this, reply_msg));
+}
+
+void PepperMessageFilter::GetFontFamiliesComplete(
+ IPC::Message* reply_msg,
+ scoped_refptr<content::FontListResult> result) {
+ ListValue* input = result->list.get();
+
+ std::string output;
+ for (size_t i = 0; i < input->GetSize(); i++) {
+ ListValue* cur_font;
+ if (!input->GetList(i, &cur_font))
+ continue;
+
+ // Each entry in the list is actually a list of (font name, localized name).
+ // We only care about the regular name.
+ std::string font_name;
+ if (!cur_font->GetString(0, &font_name))
+ continue;
+
+ // Font names are separated with nulls. We also want an explicit null at
+ // the end of the string (Pepper strings aren't null terminated so since
+ // we specify there will be a null, it should actually be in the string).
+ output.append(font_name);
+ output.push_back(0);
+ }
+
+ PpapiHostMsg_PPBFont_GetFontFamilies::WriteReplyParams(reply_msg, output);
+ Send(reply_msg);
+}
+
+net::HostResolver* PepperMessageFilter::GetHostResolver() {
+ if (resource_context_)
+ return resource_context_->host_resolver();
+ return host_resolver_;
+}
diff --git a/content/browser/renderer_host/pepper_message_filter.h b/content/browser/renderer_host/pepper_message_filter.h
index dbd2f77..f047ec9 100644
--- a/content/browser/renderer_host/pepper_message_filter.h
+++ b/content/browser/renderer_host/pepper_message_filter.h
@@ -12,6 +12,7 @@
#include "base/process.h"
#include "base/time.h"
#include "content/browser/browser_message_filter.h"
+#include "content/browser/font_list_async.h"
#include "ppapi/c/private/ppb_flash_net_connector.h"
namespace content {
@@ -20,19 +21,26 @@ class ResourceContext;
namespace net {
class AddressList;
+class HostResolver;
}
+// This class is used in two contexts, both supporting PPAPI plugins. The first
+// is on the renderer->browser channel, to handle requests from in-process
+// PPAPI plugins and any requests that the PPAPI implementation code in the
+// renderer needs to make. The second is on the plugin->browser channel to
+// handle requests that out-of-process plugins send directly to the browser.
class PepperMessageFilter : public BrowserMessageFilter {
public:
explicit PepperMessageFilter(
- const content::ResourceContext* resource_context);
+ const content::ResourceContext* resource_context);
+ explicit PepperMessageFilter(net::HostResolver* host_resolver);
virtual ~PepperMessageFilter();
- private:
// BrowserMessageFilter methods.
virtual bool OnMessageReceived(const IPC::Message& message,
bool* message_was_ok);
+ private:
#if defined(ENABLE_FLAPPER_HACKS)
// Message handlers.
void OnConnectTcp(int routing_id,
@@ -66,8 +74,24 @@ class PepperMessageFilter : public BrowserMessageFilter {
#endif // ENABLE_FLAPPER_HACKS
void OnGetLocalTimeZoneOffset(base::Time t, double* result);
+ void OnGetFontFamilies(IPC::Message* reply);
+
+ // Callback when the font list has been retrieved on a background thread.
+ void GetFontFamiliesComplete(IPC::Message* reply_msg,
+ scoped_refptr<content::FontListResult> result);
+ // Returns the host resolver (it may come from the resource context or the
+ // host_resolver_ member).
+ net::HostResolver* GetHostResolver();
+
+ // When non-NULL, this should be used instead of the host_resolver_.
const content::ResourceContext* const resource_context_;
+
+ // When non-NULL, this should be used instead of the resource_context_. Use
+ // GetHostResolver instead of accessing directly.
+ net::HostResolver* host_resolver_;
+
+ DISALLOW_COPY_AND_ASSIGN(PepperMessageFilter);
};
#endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_MESSAGE_FILTER_H_
diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc
index cdcaf06..361d0e9 100644
--- a/content/browser/renderer_host/render_message_filter.cc
+++ b/content/browser/renderer_host/render_message_filter.cc
@@ -166,8 +166,10 @@ class OpenChannelToPpapiPluginCallback : public RenderMessageCompletionCallback,
public PpapiPluginProcessHost::Client {
public:
OpenChannelToPpapiPluginCallback(RenderMessageFilter* filter,
+ const content::ResourceContext* context,
IPC::Message* reply_msg)
- : RenderMessageCompletionCallback(filter, reply_msg) {
+ : RenderMessageCompletionCallback(filter, reply_msg),
+ context_(context) {
}
virtual void GetChannelInfo(base::ProcessHandle* renderer_handle,
@@ -182,6 +184,13 @@ class OpenChannelToPpapiPluginCallback : public RenderMessageCompletionCallback,
reply_msg(), plugin_process_handle, channel_handle);
SendReplyAndDeleteThis();
}
+
+ virtual const content::ResourceContext* GetResourceContext() {
+ return context_;
+ }
+
+ private:
+ const content::ResourceContext* context_;
};
class OpenChannelToPpapiBrokerCallback : public PpapiBrokerProcessHost::Client {
@@ -606,7 +615,9 @@ void RenderMessageFilter::OnOpenChannelToPepperPlugin(
const FilePath& path,
IPC::Message* reply_msg) {
plugin_service_->OpenChannelToPpapiPlugin(
- path, new OpenChannelToPpapiPluginCallback(this, reply_msg));
+ path,
+ new OpenChannelToPpapiPluginCallback(
+ this, &resource_context_, reply_msg));
}
void RenderMessageFilter::OnOpenChannelToPpapiBroker(int routing_id,