diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-11 01:19:28 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-11 01:19:28 +0000 |
commit | e2a89013275843d878d657cf9b717931c3ea1350 (patch) | |
tree | 346c609cc6b3668dda3cc494ffb0c5c7726e2c55 | |
parent | e7a30e3036462352093740b9b9ca4fd52bf585cb (diff) | |
download | chromium_src-e2a89013275843d878d657cf9b717931c3ea1350.zip chromium_src-e2a89013275843d878d657cf9b717931c3ea1350.tar.gz chromium_src-e2a89013275843d878d657cf9b717931c3ea1350.tar.bz2 |
Move ResourceDispatcherHostDelegate to content\public\common. I've added a set delegate function on ChildThread (which will soon be on content::ChildThread interface) so that we don't have to expose ResourceDispatcher to embedders.
BUG=98716
Review URL: http://codereview.chromium.org/8224019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104832 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/DEPS | 1 | ||||
-rw-r--r-- | chrome/renderer/chrome_render_process_observer.cc | 10 | ||||
-rw-r--r-- | chrome/renderer/chrome_render_process_observer.h | 9 | ||||
-rw-r--r-- | chrome/renderer/mock_render_thread.cc | 4 | ||||
-rw-r--r-- | chrome/renderer/mock_render_thread.h | 1 | ||||
-rw-r--r-- | content/DEPS | 1 | ||||
-rw-r--r-- | content/common/child_thread.cc | 5 | ||||
-rw-r--r-- | content/common/child_thread.h | 8 | ||||
-rw-r--r-- | content/common/resource_dispatcher.cc | 2 | ||||
-rw-r--r-- | content/common/resource_dispatcher.h | 9 | ||||
-rw-r--r-- | content/common/resource_dispatcher_delegate.cc | 27 | ||||
-rw-r--r-- | content/content_common.gypi | 3 | ||||
-rw-r--r-- | content/public/common/resource_dispatcher_delegate.h (renamed from content/common/resource_dispatcher_delegate.h) | 17 | ||||
-rw-r--r-- | content/public/renderer/render_thread.h | 2 | ||||
-rw-r--r-- | content/renderer/render_thread_impl.cc | 4 | ||||
-rw-r--r-- | content/renderer/render_thread_impl.h | 1 |
16 files changed, 45 insertions, 59 deletions
diff --git a/chrome/DEPS b/chrome/DEPS index 4d20732..2580f54 100644 --- a/chrome/DEPS +++ b/chrome/DEPS @@ -13,6 +13,7 @@ include_rules = [ "+chrome/test", "-content", "+content/common", + "+content/public/common", "+content/test", # Don't allow inclusion of these other libs we shouldn't be calling directly. diff --git a/chrome/renderer/chrome_render_process_observer.cc b/chrome/renderer/chrome_render_process_observer.cc index ddd02b6..dd6edbd 100644 --- a/chrome/renderer/chrome_render_process_observer.cc +++ b/chrome/renderer/chrome_render_process_observer.cc @@ -21,9 +21,9 @@ #include "chrome/renderer/chrome_content_renderer_client.h" #include "chrome/renderer/content_settings_observer.h" #include "chrome/renderer/security_filter_peer.h" -#include "content/common/resource_dispatcher.h" -#include "content/common/resource_dispatcher_delegate.h" +#include "content/common/child_thread.h" #include "content/common/view_messages.h" +#include "content/public/common/resource_dispatcher_delegate.h" #include "content/public/renderer/render_thread.h" #include "content/public/renderer/render_view_visitor.h" #include "content/public/renderer/render_view.h" @@ -58,7 +58,7 @@ namespace { static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */; -class RendererResourceDelegate : public ResourceDispatcherDelegate { +class RendererResourceDelegate : public content::ResourceDispatcherDelegate { public: RendererResourceDelegate() : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { @@ -211,7 +211,9 @@ ChromeRenderProcessObserver::ChromeRenderProcessObserver( RenderThread* thread = RenderThread::Get(); resource_delegate_.reset(new RendererResourceDelegate()); - thread->GetResourceDispatcher()->set_delegate(resource_delegate_.get()); + + ChildThread* child_thread = ChildThread::current(); + child_thread->SetResourceDispatcherDelegate(resource_delegate_.get()); #if defined(OS_POSIX) thread->AddFilter(new SuicideOnChannelErrorFilter()); diff --git a/chrome/renderer/chrome_render_process_observer.h b/chrome/renderer/chrome_render_process_observer.h index b7740e6..7c14c24 100644 --- a/chrome/renderer/chrome_render_process_observer.h +++ b/chrome/renderer/chrome_render_process_observer.h @@ -13,13 +13,16 @@ #include "base/memory/scoped_ptr.h" #include "content/public/renderer/render_process_observer.h" +class GURL; +struct ContentSettings; + namespace chrome { class ChromeContentRendererClient; } -class GURL; +namespace content { class ResourceDispatcherDelegate; -struct ContentSettings; +} // This class filters the incoming control messages (i.e. ones not destined for // a RenderView) for Chrome specific messages that the content layer doesn't @@ -62,7 +65,7 @@ class ChromeRenderProcessObserver : public content::RenderProcessObserver { void OnPurgeMemory(); static bool is_incognito_process_; - scoped_ptr<ResourceDispatcherDelegate> resource_delegate_; + scoped_ptr<content::ResourceDispatcherDelegate> resource_delegate_; chrome::ChromeContentRendererClient* client_; // If true, the web cache shall be cleared before the next navigation event. bool clear_cache_pending_; diff --git a/chrome/renderer/mock_render_thread.cc b/chrome/renderer/mock_render_thread.cc index e36047e..982e5ac 100644 --- a/chrome/renderer/mock_render_thread.cc +++ b/chrome/renderer/mock_render_thread.cc @@ -66,10 +66,6 @@ IPC::SyncChannel* MockRenderThread::GetChannel() { return NULL; } -ResourceDispatcher* MockRenderThread::GetResourceDispatcher() { - return NULL; -} - std::string MockRenderThread::GetLocale() { return std::string(); } diff --git a/chrome/renderer/mock_render_thread.h b/chrome/renderer/mock_render_thread.h index b0beefd..31ce743 100644 --- a/chrome/renderer/mock_render_thread.h +++ b/chrome/renderer/mock_render_thread.h @@ -46,7 +46,6 @@ class MockRenderThread : public content::RenderThread { virtual bool Send(IPC::Message* msg) OVERRIDE; virtual MessageLoop* GetMessageLoop() OVERRIDE; virtual IPC::SyncChannel* GetChannel() OVERRIDE; - virtual ResourceDispatcher* GetResourceDispatcher() OVERRIDE; virtual std::string GetLocale() OVERRIDE; virtual void AddRoute(int32 routing_id, IPC::Channel::Listener* listener) OVERRIDE; diff --git a/content/DEPS b/content/DEPS index 8742fd4..c47f7c4 100644 --- a/content/DEPS +++ b/content/DEPS @@ -19,6 +19,7 @@ include_rules = [ # directories in content/ so we disallow all of them. "-content", "+content/common", + "+content/public/common", "+content/test", "+dbus", diff --git a/content/common/child_thread.cc b/content/common/child_thread.cc index bfde285..81dbd7b 100644 --- a/content/common/child_thread.cc +++ b/content/common/child_thread.cc @@ -114,6 +114,11 @@ void ChildThread::RemoveRoute(int32 routing_id) { router_.RemoveRoute(routing_id); } +void ChildThread::SetResourceDispatcherDelegate( + content::ResourceDispatcherDelegate* delegate) { + resource_dispatcher_->set_delegate(delegate); +} + IPC::Channel::Listener* ChildThread::ResolveRoute(int32 routing_id) { DCHECK(MessageLoop::current() == message_loop()); diff --git a/content/common/child_thread.h b/content/common/child_thread.h index 356ffd5..f7cf5dc 100644 --- a/content/common/child_thread.h +++ b/content/common/child_thread.h @@ -24,6 +24,10 @@ class SyncChannel; class SyncMessageFilter; } +namespace content { +class ResourceDispatcherDelegate; +} + // The main thread of a child process derives from this class. class CONTENT_EXPORT ChildThread : public IPC::Channel::Listener, public IPC::Message::Sender { @@ -41,6 +45,10 @@ class CONTENT_EXPORT ChildThread : public IPC::Channel::Listener, void AddRoute(int32 routing_id, IPC::Channel::Listener* listener); void RemoveRoute(int32 routing_id); + // Set the ResourceDispatcher delegate object for this process. + void SetResourceDispatcherDelegate( + content::ResourceDispatcherDelegate* delegate); + IPC::Channel::Listener* ResolveRoute(int32 routing_id); IPC::SyncChannel* channel() { return channel_.get(); } diff --git a/content/common/resource_dispatcher.cc b/content/common/resource_dispatcher.cc index d3f5185..29e3c05d 100644 --- a/content/common/resource_dispatcher.cc +++ b/content/common/resource_dispatcher.cc @@ -13,9 +13,9 @@ #include "base/shared_memory.h" #include "base/string_util.h" #include "content/common/request_extra_data.h" -#include "content/common/resource_dispatcher_delegate.h" #include "content/common/resource_messages.h" #include "content/common/resource_response.h" +#include "content/public/common/resource_dispatcher_delegate.h" #include "net/base/net_errors.h" #include "net/base/net_util.h" #include "net/base/upload_data.h" diff --git a/content/common/resource_dispatcher.h b/content/common/resource_dispatcher.h index fd400fe..2200282 100644 --- a/content/common/resource_dispatcher.h +++ b/content/common/resource_dispatcher.h @@ -19,9 +19,12 @@ #include "ipc/ipc_channel.h" #include "webkit/glue/resource_loader_bridge.h" -class ResourceDispatcherDelegate; struct ResourceResponseHead; +namespace content { +class ResourceDispatcherDelegate; +} + // This class serves as a communication interface between the // ResourceDispatcherHost in the browser process and the ResourceLoaderBridge in // the child process. It can be used from any child process. @@ -61,7 +64,7 @@ class CONTENT_EXPORT ResourceDispatcher : public IPC::Channel::Listener { // This does not take ownership of the delegate. It is expected that the // delegate have a longer lifetime than the ResourceDispatcher. - void set_delegate(ResourceDispatcherDelegate* delegate) { + void set_delegate(content::ResourceDispatcherDelegate* delegate) { delegate_ = delegate; } @@ -153,7 +156,7 @@ class CONTENT_EXPORT ResourceDispatcher : public IPC::Channel::Listener { ScopedRunnableMethodFactory<ResourceDispatcher> method_factory_; - ResourceDispatcherDelegate* delegate_; + content::ResourceDispatcherDelegate* delegate_; DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher); }; diff --git a/content/common/resource_dispatcher_delegate.cc b/content/common/resource_dispatcher_delegate.cc deleted file mode 100644 index 75776d5..0000000 --- a/content/common/resource_dispatcher_delegate.cc +++ /dev/null @@ -1,27 +0,0 @@ -// 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/common/resource_dispatcher_delegate.h" - -ResourceDispatcherDelegate::ResourceDispatcherDelegate() { -} - -ResourceDispatcherDelegate::~ResourceDispatcherDelegate() { -} - -webkit_glue::ResourceLoaderBridge::Peer* - ResourceDispatcherDelegate::OnRequestComplete( - webkit_glue::ResourceLoaderBridge::Peer* current_peer, - ResourceType::Type resource_type, - const net::URLRequestStatus& status) { - return NULL; -} - -webkit_glue::ResourceLoaderBridge::Peer* - ResourceDispatcherDelegate::OnReceivedResponse( - webkit_glue::ResourceLoaderBridge::Peer* current_peer, - const std::string& mime_type, - const GURL& url) { - return NULL; -} diff --git a/content/content_common.gypi b/content/content_common.gypi index c32f977..382632d 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -28,6 +28,7 @@ '../base/base.gyp:base', ], 'sources': [ + 'public/common/resource_dispatcher_delegate.h', 'common/appcache/appcache_backend_proxy.cc', 'common/appcache/appcache_backend_proxy.h', 'common/appcache/appcache_dispatcher.cc', @@ -208,8 +209,6 @@ 'common/request_extra_data.h', 'common/resource_dispatcher.cc', 'common/resource_dispatcher.h', - 'common/resource_dispatcher_delegate.cc', - 'common/resource_dispatcher_delegate.h', 'common/resource_messages.h', 'common/resource_response.cc', 'common/resource_response.h', diff --git a/content/common/resource_dispatcher_delegate.h b/content/public/common/resource_dispatcher_delegate.h index c19ed57..8f3ff61 100644 --- a/content/common/resource_dispatcher_delegate.h +++ b/content/public/common/resource_dispatcher_delegate.h @@ -2,29 +2,32 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_COMMON_RESOURCE_DISPATCHER_DELEGATE_H_ -#define CONTENT_COMMON_RESOURCE_DISPATCHER_DELEGATE_H_ +#ifndef CONTENT_PUBLIC_COMMON_RESOURCE_DISPATCHER_DELEGATE_H_ +#define CONTENT_PUBLIC_COMMON_RESOURCE_DISPATCHER_DELEGATE_H_ #pragma once #include "content/common/content_export.h" #include "webkit/glue/resource_loader_bridge.h" +namespace content { + // Interface that allows observing request events and optionally replacing the // peer. class CONTENT_EXPORT ResourceDispatcherDelegate { public: - ResourceDispatcherDelegate(); - virtual ~ResourceDispatcherDelegate(); + virtual ~ResourceDispatcherDelegate() {} virtual webkit_glue::ResourceLoaderBridge::Peer* OnRequestComplete( webkit_glue::ResourceLoaderBridge::Peer* current_peer, ResourceType::Type resource_type, - const net::URLRequestStatus& status); + const net::URLRequestStatus& status) = 0; virtual webkit_glue::ResourceLoaderBridge::Peer* OnReceivedResponse( webkit_glue::ResourceLoaderBridge::Peer* current_peer, const std::string& mime_type, - const GURL& url); + const GURL& url) = 0; }; -#endif // CONTENT_COMMON_RESOURCE_DISPATCHER_DELEGATE_H_ +} // namespace content + +#endif // CONTENT_PUBLIC_COMMON_RESOURCE_DISPATCHER_DELEGATE_H_ diff --git a/content/public/renderer/render_thread.h b/content/public/renderer/render_thread.h index a7659e4..377f6db 100644 --- a/content/public/renderer/render_thread.h +++ b/content/public/renderer/render_thread.h @@ -15,7 +15,6 @@ #endif class MessageLoop; -class ResourceDispatcher; namespace IPC { class SyncChannel; @@ -40,7 +39,6 @@ class CONTENT_EXPORT RenderThread : public IPC::Message::Sender { virtual MessageLoop* GetMessageLoop() = 0; virtual IPC::SyncChannel* GetChannel() = 0; - virtual ResourceDispatcher* GetResourceDispatcher() = 0; virtual std::string GetLocale() = 0; // Called to add or remove a listener for a particular message routing ID. diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc index f1089b7..91939d4 100644 --- a/content/renderer/render_thread_impl.cc +++ b/content/renderer/render_thread_impl.cc @@ -340,10 +340,6 @@ IPC::SyncChannel* RenderThreadImpl::GetChannel() { return channel(); } -ResourceDispatcher* RenderThreadImpl::GetResourceDispatcher() { - return resource_dispatcher(); -} - std::string RenderThreadImpl::GetLocale() { // The browser process should have passed the locale to the renderer via the // --lang command line flag. In single process mode, this will return the diff --git a/content/renderer/render_thread_impl.h b/content/renderer/render_thread_impl.h index 092dcb4..0855ce8 100644 --- a/content/renderer/render_thread_impl.h +++ b/content/renderer/render_thread_impl.h @@ -93,7 +93,6 @@ class CONTENT_EXPORT RenderThreadImpl : public content::RenderThread, virtual bool Send(IPC::Message* msg) OVERRIDE; virtual MessageLoop* GetMessageLoop() OVERRIDE; virtual IPC::SyncChannel* GetChannel() OVERRIDE; - virtual ResourceDispatcher* GetResourceDispatcher() OVERRIDE; virtual std::string GetLocale() OVERRIDE; virtual void AddRoute(int32 routing_id, IPC::Channel::Listener* listener) OVERRIDE; |