diff options
author | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-22 05:42:36 +0000 |
---|---|---|
committer | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-22 05:42:36 +0000 |
commit | 0157282494c1096cef55f04d7b8936c7db022679 (patch) | |
tree | 33d30478c95e60b4ba629b098db06ae2d1418278 /webkit/glue | |
parent | 745816be61e207da7cef1f839591bfb35bd15fd3 (diff) | |
download | chromium_src-0157282494c1096cef55f04d7b8936c7db022679.zip chromium_src-0157282494c1096cef55f04d7b8936c7db022679.tar.gz chromium_src-0157282494c1096cef55f04d7b8936c7db022679.tar.bz2 |
Move some webkit_glue embedder functions into WebKitPlatformSupport virtual methods
This moves the functions into a pattern that is component-friendly.
BUG=98755
TEST=chrome test_shell test_shell_tests browser_tests DumpRenderTree
Review URL: http://codereview.chromium.org/8602002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111101 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/resource_loader_bridge.h | 21 | ||||
-rw-r--r-- | webkit/glue/webkit_glue.h | 29 | ||||
-rw-r--r-- | webkit/glue/webkitplatformsupport_impl.cc | 11 | ||||
-rw-r--r-- | webkit/glue/webkitplatformsupport_impl.h | 35 | ||||
-rw-r--r-- | webkit/glue/websocketstreamhandle_bridge.h | 4 | ||||
-rw-r--r-- | webkit/glue/websocketstreamhandle_impl.cc | 17 | ||||
-rw-r--r-- | webkit/glue/websocketstreamhandle_impl.h | 5 | ||||
-rw-r--r-- | webkit/glue/weburlloader_impl.cc | 18 | ||||
-rw-r--r-- | webkit/glue/weburlloader_impl.h | 5 |
9 files changed, 80 insertions, 65 deletions
diff --git a/webkit/glue/resource_loader_bridge.h b/webkit/glue/resource_loader_bridge.h index 6711039..da0a36e 100644 --- a/webkit/glue/resource_loader_bridge.h +++ b/webkit/glue/resource_loader_bridge.h @@ -4,8 +4,7 @@ // // The intent of this file is to provide a type-neutral abstraction between // Chrome and WebKit for resource loading. This pure-virtual interface is -// implemented by the embedder, which also provides a factory method Create -// to instantiate this object. +// implemented by the embedder. // // One of these objects will be created by WebKit for each request. WebKit // will own the pointer to the bridge, and will delete it when the request is @@ -197,7 +196,8 @@ struct ResourceResponseInfo { class ResourceLoaderBridge { public: - // Structure used when calling ResourceLoaderBridge::Create(). + // Structure used when calling + // WebKitPlatformSupportImpl::CreateResourceLoader(). struct RequestInfo { RequestInfo(); ~RequestInfo(); @@ -329,16 +329,10 @@ class ResourceLoaderBridge { const base::Time& completion_time) = 0; }; - // use Create() for construction, but anybody can delete at any time, - // INCLUDING during processing of callbacks. + // use WebKitPlatformSupportImpl::CreateResourceLoader() for construction, but + // anybody can delete at any time, INCLUDING during processing of callbacks. virtual ~ResourceLoaderBridge(); - // Call this method to make a new instance. - // - // For HTTP(S) POST requests, the AppendDataToUpload and AppendFileToUpload - // methods may be called to construct the body of the request. - static ResourceLoaderBridge* Create(const RequestInfo& request_info); - // Call this method before calling Start() to append a chunk of binary data // to the request body. May only be used with HTTP(S) POST requests. virtual void AppendDataToUpload(const char* data, int data_len) = 0; @@ -394,7 +388,10 @@ class ResourceLoaderBridge { virtual void UpdateRoutingId(int new_routing_id) = 0; protected: - // construction must go through Create() + // Construction must go through + // WebKitPlatformSupportImpl::CreateResourceLoader() + // For HTTP(S) POST requests, the AppendDataToUpload and AppendFileToUpload + // methods may be called to construct the body of the request. ResourceLoaderBridge(); private: diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h index ddbc3a3..ef00fb4 100644 --- a/webkit/glue/webkit_glue.h +++ b/webkit/glue/webkit_glue.h @@ -36,15 +36,8 @@ class WebFrame; class WebString; } -namespace webkit { -struct WebPluginInfo; -} - namespace webkit_glue { - -//---- BEGIN FUNCTIONS IMPLEMENTED BY WEBKIT/GLUE ----------------------------- - void SetJavaScriptFlags(const std::string& flags); // Turn on logging for flags in the provided comma delimited list. @@ -151,28 +144,6 @@ std::string GetInspectorProtocolVersion(); // Tells caller whether the given protocol version is supported by the. bool IsInspectorProtocolVersionSupported(const std::string& version); -//---- END FUNCTIONS IMPLEMENTED BY WEBKIT/GLUE ------------------------------- - - -//---- BEGIN FUNCTIONS IMPLEMENTED BY EMBEDDER -------------------------------- - -// Glue to get resources from the embedder. - -// Gets a localized string given a message id. Returns an empty string if the -// message id is not found. -string16 GetLocalizedString(int message_id); - -// Returns the raw data for a resource. This resource must have been -// specified as BINDATA in the relevant .rc file. -base::StringPiece GetDataResource(int resource_id); - -// Embedders implement this function to return the list of plugins to Webkit. -void GetPlugins(bool refresh, - std::vector<webkit::WebPluginInfo>* plugins); - -// ---- END FUNCTIONS IMPLEMENTED BY EMBEDDER --------------------------------- - - } // namespace webkit_glue #endif // WEBKIT_GLUE_WEBKIT_GLUE_H_ diff --git a/webkit/glue/webkitplatformsupport_impl.cc b/webkit/glue/webkitplatformsupport_impl.cc index 7c0863f..5df7d13 100644 --- a/webkit/glue/webkitplatformsupport_impl.cc +++ b/webkit/glue/webkitplatformsupport_impl.cc @@ -223,11 +223,11 @@ WebThemeEngine* WebKitPlatformSupportImpl::themeEngine() { } WebURLLoader* WebKitPlatformSupportImpl::createURLLoader() { - return new WebURLLoaderImpl(); + return new WebURLLoaderImpl(this); } WebSocketStreamHandle* WebKitPlatformSupportImpl::createSocketStreamHandle() { - return new WebSocketStreamHandleImpl(); + return new WebSocketStreamHandleImpl(this); } WebString WebKitPlatformSupportImpl::userAgent(const WebURL& url) { @@ -306,7 +306,8 @@ void WebKitPlatformSupportImpl::traceEventEnd(const char* name, void* id, namespace { -WebData loadAudioSpatializationResource(const char* name) { +WebData loadAudioSpatializationResource(WebKitPlatformSupportImpl* platform, + const char* name) { #ifdef IDR_AUDIO_SPATIALIZATION_T000_P000 const size_t kExpectedSpatializationNameLength = 31; if (strlen(name) != kExpectedSpatializationNameLength) { @@ -346,7 +347,7 @@ WebData loadAudioSpatializationResource(const char* name) { is_resource_index_good) { const int kFirstAudioResourceIndex = IDR_AUDIO_SPATIALIZATION_T000_P000; base::StringPiece resource = - GetDataResource(kFirstAudioResourceIndex + resource_index); + platform->GetDataResource(kFirstAudioResourceIndex + resource_index); return WebData(resource.data(), resource.size()); } #endif // IDR_AUDIO_SPATIALIZATION_T000_P000 @@ -434,7 +435,7 @@ WebData WebKitPlatformSupportImpl::loadResource(const char* name) { // Check the name prefix to see if it's an audio resource. if (StartsWithASCII(name, "IRC_Composite", true)) - return loadAudioSpatializationResource(name); + return loadAudioSpatializationResource(this, name); for (size_t i = 0; i < arraysize(kDataResources); ++i) { if (!strcmp(name, kDataResources[i].name)) { diff --git a/webkit/glue/webkitplatformsupport_impl.h b/webkit/glue/webkitplatformsupport_impl.h index d73e242..7ecbd3a 100644 --- a/webkit/glue/webkitplatformsupport_impl.h +++ b/webkit/glue/webkitplatformsupport_impl.h @@ -9,6 +9,7 @@ #include "base/threading/thread_local_storage.h" #include "base/timer.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebKitPlatformSupport.h" +#include "webkit/glue/resource_loader_bridge.h" #if defined(OS_WIN) #include "webkit/glue/webthemeengine_impl_win.h" #elif defined(OS_MACOSX) @@ -20,8 +21,19 @@ class MessageLoop; +namespace webkit { +struct WebPluginInfo; +} + +namespace WebKit { +class WebSocketStreamHandle; +} + namespace webkit_glue { +class WebSocketStreamHandleDelegate; +class WebSocketStreamHandleBridge; + class WebKitPlatformSupportImpl : public WebKit::WebKitPlatformSupport { public: WebKitPlatformSupportImpl(); @@ -82,6 +94,29 @@ class WebKitPlatformSupportImpl : public WebKit::WebKitPlatformSupport { virtual WebKit::WebThread* createThread(const char* name); virtual WebKit::WebThread* currentThread(); + + // Embedder functions. The following are not implemented by the glue layer and + // need to be specialized by the embedder. + + // Gets a localized string given a message id. Returns an empty string if the + // message id is not found. + virtual string16 GetLocalizedString(int message_id) = 0; + + // Returns the raw data for a resource. This resource must have been + // specified as BINDATA in the relevant .rc file. + virtual base::StringPiece GetDataResource(int resource_id) = 0; + + // Returns the list of plugins. + virtual void GetPlugins(bool refresh, + std::vector<webkit::WebPluginInfo>* plugins) = 0; + // Creates a ResourceLoaderBridge. + virtual ResourceLoaderBridge* CreateResourceLoader( + const ResourceLoaderBridge::RequestInfo& request_info) = 0; + // Creates a WebSocketStreamHandleBridge. + virtual WebSocketStreamHandleBridge* CreateWebSocketBridge( + WebKit::WebSocketStreamHandle* handle, + WebSocketStreamHandleDelegate* delegate) = 0; + void SuspendSharedTimer(); void ResumeSharedTimer(); diff --git a/webkit/glue/websocketstreamhandle_bridge.h b/webkit/glue/websocketstreamhandle_bridge.h index d051712..c1712cb 100644 --- a/webkit/glue/websocketstreamhandle_bridge.h +++ b/webkit/glue/websocketstreamhandle_bridge.h @@ -23,10 +23,6 @@ class WebSocketStreamHandleDelegate; class WebSocketStreamHandleBridge : public base::RefCountedThreadSafe<WebSocketStreamHandleBridge> { public: - static WebSocketStreamHandleBridge* Create( - WebKit::WebSocketStreamHandle* handle, - WebSocketStreamHandleDelegate* delegate); - virtual void Connect(const GURL& url) = 0; virtual bool Send(const std::vector<char>& data) = 0; diff --git a/webkit/glue/websocketstreamhandle_impl.cc b/webkit/glue/websocketstreamhandle_impl.cc index 9e26896..d9cf197 100644 --- a/webkit/glue/websocketstreamhandle_impl.cc +++ b/webkit/glue/websocketstreamhandle_impl.cc @@ -15,6 +15,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebData.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebSocketStreamHandleClient.h" +#include "webkit/glue/webkitplatformsupport_impl.h" #include "webkit/glue/websocketstreamhandle_bridge.h" #include "webkit/glue/websocketstreamhandle_delegate.h" @@ -33,7 +34,7 @@ class WebSocketStreamHandleImpl::Context client_ = client; } - void Connect(const WebKit::WebURL& url); + void Connect(const WebKit::WebURL& url, WebKitPlatformSupportImpl* platform); bool Send(const WebKit::WebData& data); void Close(); @@ -71,10 +72,12 @@ WebSocketStreamHandleImpl::Context::Context(WebSocketStreamHandleImpl* handle) bridge_(NULL) { } -void WebSocketStreamHandleImpl::Context::Connect(const WebKit::WebURL& url) { +void WebSocketStreamHandleImpl::Context::Connect( + const WebKit::WebURL& url, + WebKitPlatformSupportImpl* platform) { VLOG(1) << "Connect url=" << url; DCHECK(!bridge_); - bridge_ = WebSocketStreamHandleBridge::Create(handle_, this); + bridge_ = platform->CreateWebSocketBridge(handle_, this); AddRef(); // Will be released by DidClose(). bridge_->Connect(url); } @@ -138,8 +141,10 @@ void WebSocketStreamHandleImpl::Context::DidClose( // WebSocketStreamHandleImpl ------------------------------------------------ -WebSocketStreamHandleImpl::WebSocketStreamHandleImpl() - : ALLOW_THIS_IN_INITIALIZER_LIST(context_(new Context(this))) { +WebSocketStreamHandleImpl::WebSocketStreamHandleImpl( + WebKitPlatformSupportImpl* platform) + : ALLOW_THIS_IN_INITIALIZER_LIST(context_(new Context(this))), + platform_(platform) { } WebSocketStreamHandleImpl::~WebSocketStreamHandleImpl() { @@ -155,7 +160,7 @@ void WebSocketStreamHandleImpl::connect( DCHECK(!context_->client()); context_->set_client(client); - context_->Connect(url); + context_->Connect(url, platform_); } bool WebSocketStreamHandleImpl::send(const WebKit::WebData& data) { diff --git a/webkit/glue/websocketstreamhandle_impl.h b/webkit/glue/websocketstreamhandle_impl.h index e018388..9ce5d77 100644 --- a/webkit/glue/websocketstreamhandle_impl.h +++ b/webkit/glue/websocketstreamhandle_impl.h @@ -10,9 +10,11 @@ namespace webkit_glue { +class WebKitPlatformSupportImpl; + class WebSocketStreamHandleImpl : public WebKit::WebSocketStreamHandle { public: - WebSocketStreamHandleImpl(); + explicit WebSocketStreamHandleImpl(WebKitPlatformSupportImpl* platform); virtual ~WebSocketStreamHandleImpl(); // WebSocketStreamHandle methods: @@ -25,6 +27,7 @@ class WebSocketStreamHandleImpl : public WebKit::WebSocketStreamHandle { private: class Context; scoped_refptr<Context> context_; + WebKitPlatformSupportImpl* platform_; DISALLOW_COPY_AND_ASSIGN(WebSocketStreamHandleImpl); }; diff --git a/webkit/glue/weburlloader_impl.cc b/webkit/glue/weburlloader_impl.cc index 1d8f21c..9e7c3eb 100644 --- a/webkit/glue/weburlloader_impl.cc +++ b/webkit/glue/weburlloader_impl.cc @@ -32,6 +32,7 @@ #include "webkit/glue/multipart_response_delegate.h" #include "webkit/glue/resource_loader_bridge.h" #include "webkit/glue/webkit_glue.h" +#include "webkit/glue/webkitplatformsupport_impl.h" using base::Time; using base::TimeDelta; @@ -262,7 +263,8 @@ class WebURLLoaderImpl::Context : public base::RefCounted<Context>, void SetDefersLoading(bool value); void Start( const WebURLRequest& request, - ResourceLoaderBridge::SyncLoadResponse* sync_load_response); + ResourceLoaderBridge::SyncLoadResponse* sync_load_response, + WebKitPlatformSupportImpl* platform); void UpdateRoutingId(int new_routing_id); // ResourceLoaderBridge::Peer methods: @@ -332,7 +334,8 @@ void WebURLLoaderImpl::Context::UpdateRoutingId(int new_routing_id) { void WebURLLoaderImpl::Context::Start( const WebURLRequest& request, - ResourceLoaderBridge::SyncLoadResponse* sync_load_response) { + ResourceLoaderBridge::SyncLoadResponse* sync_load_response, + WebKitPlatformSupportImpl* platform) { DCHECK(!bridge_.get()); request_ = request; // Save the request. @@ -413,7 +416,7 @@ void WebURLLoaderImpl::Context::Start( request_info.download_to_file = request.downloadToFile(); request_info.has_user_gesture = request.hasUserGesture(); request_info.extra_data = request.extraData(); - bridge_.reset(ResourceLoaderBridge::Create(request_info)); + bridge_.reset(platform->CreateResourceLoader(request_info)); if (!request.httpBody().isNull()) { // GET and HEAD requests shouldn't have http bodies. @@ -686,8 +689,9 @@ void WebURLLoaderImpl::Context::HandleDataURL() { // WebURLLoaderImpl ----------------------------------------------------------- -WebURLLoaderImpl::WebURLLoaderImpl() - : ALLOW_THIS_IN_INITIALIZER_LIST(context_(new Context(this))) { +WebURLLoaderImpl::WebURLLoaderImpl(WebKitPlatformSupportImpl* platform) + : ALLOW_THIS_IN_INITIALIZER_LIST(context_(new Context(this))), + platform_(platform) { } WebURLLoaderImpl::~WebURLLoaderImpl() { @@ -699,7 +703,7 @@ void WebURLLoaderImpl::loadSynchronously(const WebURLRequest& request, WebURLError& error, WebData& data) { ResourceLoaderBridge::SyncLoadResponse sync_load_response; - context_->Start(request, &sync_load_response); + context_->Start(request, &sync_load_response, platform_); const GURL& final_url = sync_load_response.url; @@ -727,7 +731,7 @@ void WebURLLoaderImpl::loadAsynchronously(const WebURLRequest& request, DCHECK(!context_->client()); context_->set_client(client); - context_->Start(request, NULL); + context_->Start(request, NULL, platform_); } void WebURLLoaderImpl::cancel() { diff --git a/webkit/glue/weburlloader_impl.h b/webkit/glue/weburlloader_impl.h index ace1cdb..226c2d1 100644 --- a/webkit/glue/weburlloader_impl.h +++ b/webkit/glue/weburlloader_impl.h @@ -10,9 +10,11 @@ namespace webkit_glue { +class WebKitPlatformSupportImpl; + class WebURLLoaderImpl : public WebKit::WebURLLoader { public: - WebURLLoaderImpl(); + explicit WebURLLoaderImpl(WebKitPlatformSupportImpl* platform); virtual ~WebURLLoaderImpl(); // WebURLLoader methods: @@ -32,6 +34,7 @@ class WebURLLoaderImpl : public WebKit::WebURLLoader { private: class Context; scoped_refptr<Context> context_; + WebKitPlatformSupportImpl* platform_; }; } // namespace webkit_glue |