diff options
author | ukai@chromium.org <ukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-07 06:13:39 +0000 |
---|---|---|
committer | ukai@chromium.org <ukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-07 06:13:39 +0000 |
commit | 7661f67398aa39e42346892bf33258db69ac9da7 (patch) | |
tree | af87943a3c633eb09c73f76735fdb783a97ddbe5 | |
parent | 703e4d66f618720ca07ce00ff3fbe68810a661c3 (diff) | |
download | chromium_src-7661f67398aa39e42346892bf33258db69ac9da7.zip chromium_src-7661f67398aa39e42346892bf33258db69ac9da7.tar.gz chromium_src-7661f67398aa39e42346892bf33258db69ac9da7.tar.bz2 |
WebSocket in Worker: render_thread->child_thread change.
SocketStream should be handled in ChildThread instead of RenderThread to be used in Worker process.
Move SocketStream in chrome/common to satisfy check_deps.
BUG=27618
TEST=none
Review URL: http://codereview.chromium.org/443015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33954 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-x | chrome/chrome.gyp | 8 | ||||
-rw-r--r-- | chrome/common/child_thread.cc | 4 | ||||
-rw-r--r-- | chrome/common/child_thread.h | 8 | ||||
-rw-r--r-- | chrome/common/socket_stream_dispatcher.cc (renamed from chrome/renderer/socket_stream_dispatcher.cc) | 27 | ||||
-rw-r--r-- | chrome/common/socket_stream_dispatcher.h (renamed from chrome/renderer/socket_stream_dispatcher.h) | 6 | ||||
-rw-r--r-- | chrome/renderer/render_thread.cc | 4 | ||||
-rw-r--r-- | chrome/renderer/render_thread.h | 6 | ||||
-rw-r--r-- | chrome/renderer/renderer_glue.cc | 4 |
8 files changed, 35 insertions, 32 deletions
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 7d9cf65..6b0bab5 100755 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -612,6 +612,8 @@ 'common/message_router.cc', 'common/message_router.h', 'common/mru_cache.h', + 'common/nacl_messages.h', + 'common/nacl_messages_internal.h', 'common/navigation_gesture.h', 'common/navigation_types.h', 'common/native_web_keyboard_event.h', @@ -665,8 +667,8 @@ 'common/spellcheck_common.h', 'common/security_filter_peer.cc', 'common/security_filter_peer.h', - 'common/nacl_messages.h', - 'common/nacl_messages_internal.h', + 'common/socket_stream_dispatcher.cc', + 'common/socket_stream_dispatcher.h', 'common/sqlite_compiled_statement.cc', 'common/sqlite_compiled_statement.h', 'common/sqlite_utils.cc', @@ -1017,8 +1019,6 @@ 'renderer/renderer_webstoragenamespace_impl.h', 'renderer/renderer_web_database_observer.cc', 'renderer/renderer_web_database_observer.h', - 'renderer/socket_stream_dispatcher.cc', - 'renderer/socket_stream_dispatcher.h', 'renderer/spellchecker/spellcheck.cc', 'renderer/spellchecker/spellcheck.h', 'renderer/spellchecker/spellcheck_worditerator.cc', diff --git a/chrome/common/child_thread.cc b/chrome/common/child_thread.cc index 48358f1..cb145ae 100644 --- a/chrome/common/child_thread.cc +++ b/chrome/common/child_thread.cc @@ -10,6 +10,7 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/notification_service.h" #include "chrome/common/plugin_messages.h" +#include "chrome/common/socket_stream_dispatcher.h" #include "ipc/ipc_logging.h" #include "ipc/ipc_message.h" #include "ipc/ipc_switches.h" @@ -45,6 +46,7 @@ void ChildThread::Init() { #endif resource_dispatcher_.reset(new ResourceDispatcher(this)); + socket_stream_dispatcher_.reset(new SocketStreamDispatcher()); // When running in unit tests, there is already a NotificationService object. // Since only one can exist at a time per thread, check first. @@ -97,6 +99,8 @@ void ChildThread::OnMessageReceived(const IPC::Message& msg) { // Resource responses are sent to the resource dispatcher. if (resource_dispatcher_->OnMessageReceived(msg)) return; + if (socket_stream_dispatcher_->OnMessageReceived(msg)) + return; bool handled = true; IPC_BEGIN_MESSAGE_MAP(ChildThread, msg) diff --git a/chrome/common/child_thread.h b/chrome/common/child_thread.h index 2082b08..63464fe 100644 --- a/chrome/common/child_thread.h +++ b/chrome/common/child_thread.h @@ -13,6 +13,7 @@ #include "ipc/ipc_message.h" class NotificationService; +class SocketStreamDispatcher; // The main thread of a child process derives from this class. class ChildThread : public IPC::Channel::Listener, @@ -35,6 +36,10 @@ class ChildThread : public IPC::Channel::Listener, return resource_dispatcher_.get(); } + SocketStreamDispatcher* socket_stream_dispatcher() { + return socket_stream_dispatcher_.get(); + } + MessageLoop* message_loop() { return message_loop_; } // Returns the one child thread. @@ -72,6 +77,9 @@ class ChildThread : public IPC::Channel::Listener, // Handles resource loads for this process. scoped_ptr<ResourceDispatcher> resource_dispatcher_; + // Handles SocketStream for this process. + scoped_ptr<SocketStreamDispatcher> socket_stream_dispatcher_; + // If true, checks with the browser process before shutdown. This avoids race // conditions if the process refcount is 0 but there's an IPC message inflight // that would addref it. diff --git a/chrome/renderer/socket_stream_dispatcher.cc b/chrome/common/socket_stream_dispatcher.cc index aa9caec..97aed21 100644 --- a/chrome/renderer/socket_stream_dispatcher.cc +++ b/chrome/common/socket_stream_dispatcher.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/renderer/socket_stream_dispatcher.h" +#include "chrome/common/socket_stream_dispatcher.h" #include <vector> #include "base/id_map.h" #include "base/ref_counted.h" +#include "chrome/common/child_thread.h" #include "chrome/common/render_messages.h" #include "chrome/common/net/socket_stream.h" -#include "chrome/renderer/render_thread.h" #include "googleurl/src/gurl.h" #include "webkit/glue/websocketstreamhandle_bridge.h" #include "webkit/glue/websocketstreamhandle_delegate.h" @@ -21,11 +21,11 @@ class IPCWebSocketStreamHandleBridge : public webkit_glue::WebSocketStreamHandleBridge { public: IPCWebSocketStreamHandleBridge( - IPC::Message::Sender* sender, + ChildThread* child_thread, WebKit::WebSocketStreamHandle* handle, webkit_glue::WebSocketStreamHandleDelegate* delegate) : socket_id_(chrome_common_net::kNoSocketId), - sender_(sender), + child_thread_(child_thread), handle_(handle), delegate_(delegate) {} @@ -49,7 +49,7 @@ class IPCWebSocketStreamHandleBridge void DoConnect(const GURL& url); int socket_id_; - IPC::Message::Sender* sender_; + ChildThread* child_thread_; WebKit::WebSocketStreamHandle* handle_; webkit_glue::WebSocketStreamHandleDelegate* delegate_; @@ -69,15 +69,15 @@ IPCWebSocketStreamHandleBridge::~IPCWebSocketStreamHandleBridge() { DLOG(INFO) << "IPCWebSocketStreamHandleBridge destructor socket_id=" << socket_id_; if (socket_id_ != chrome_common_net::kNoSocketId) { - sender_->Send(new ViewHostMsg_Close(socket_id_)); + child_thread_->Send(new ViewHostMsg_Close(socket_id_)); socket_id_ = chrome_common_net::kNoSocketId; } } void IPCWebSocketStreamHandleBridge::Connect(const GURL& url) { - DCHECK(sender_); + DCHECK(child_thread_); DLOG(INFO) << "Connect url=" << url; - MessageLoop::current()->PostTask( + child_thread_->message_loop()->PostTask( FROM_HERE, NewRunnableMethod(this, &IPCWebSocketStreamHandleBridge::DoConnect, url)); @@ -86,7 +86,8 @@ void IPCWebSocketStreamHandleBridge::Connect(const GURL& url) { bool IPCWebSocketStreamHandleBridge::Send( const std::vector<char>& data) { DLOG(INFO) << "Send data.size=" << data.size(); - if (sender_->Send(new ViewHostMsg_SocketStream_SendData(socket_id_, data))) { + if (child_thread_->Send( + new ViewHostMsg_SocketStream_SendData(socket_id_, data))) { if (delegate_) delegate_->WillSendData(handle_, &data[0], data.size()); return true; @@ -96,7 +97,7 @@ bool IPCWebSocketStreamHandleBridge::Send( void IPCWebSocketStreamHandleBridge::Close() { DLOG(INFO) << "Close socket_id" << socket_id_; - sender_->Send(new ViewHostMsg_SocketStream_Close(socket_id_)); + child_thread_->Send(new ViewHostMsg_SocketStream_Close(socket_id_)); } void IPCWebSocketStreamHandleBridge::OnConnected(int max_pending_send_allowed) { @@ -131,14 +132,15 @@ void IPCWebSocketStreamHandleBridge::OnClosed() { } void IPCWebSocketStreamHandleBridge::DoConnect(const GURL& url) { - DCHECK(sender_); + DCHECK(child_thread_); DCHECK_EQ(socket_id_, chrome_common_net::kNoSocketId); if (delegate_) delegate_->WillOpenStream(handle_, url); socket_id_ = all_bridges.Add(this); DCHECK_NE(socket_id_, chrome_common_net::kNoSocketId); - if (sender_->Send(new ViewHostMsg_SocketStream_Connect(url, socket_id_))) { + if (child_thread_->Send( + new ViewHostMsg_SocketStream_Connect(url, socket_id_))) { DLOG(INFO) << "Connect socket_id=" << socket_id_; AddRef(); // Released in OnClosed(). // TODO(ukai): timeout to OnConnected. @@ -161,7 +163,6 @@ SocketStreamDispatcher::CreateBridge( } bool SocketStreamDispatcher::OnMessageReceived(const IPC::Message& msg) { - DLOG(INFO) << "SocketStreamDispatcher::OnMessageReceived"; bool handled = true; IPC_BEGIN_MESSAGE_MAP(SocketStreamDispatcher, msg) IPC_MESSAGE_HANDLER(ViewMsg_SocketStream_Connected, OnConnected) diff --git a/chrome/renderer/socket_stream_dispatcher.h b/chrome/common/socket_stream_dispatcher.h index 5399030..8e3bbe4 100644 --- a/chrome/renderer/socket_stream_dispatcher.h +++ b/chrome/common/socket_stream_dispatcher.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_RENDERER_SOCKET_STREAM_DISPATCHER_H_ -#define CHROME_RENDERER_SOCKET_STREAM_DISPATCHER_H_ +#ifndef CHROME_COMMON_SOCKET_STREAM_DISPATCHER_H_ +#define CHROME_COMMON_SOCKET_STREAM_DISPATCHER_H_ #include <vector> @@ -35,4 +35,4 @@ class SocketStreamDispatcher { DISALLOW_COPY_AND_ASSIGN(SocketStreamDispatcher); }; -#endif // CHROME_RENDERER_SOCKET_STREAM_DISPATCHER_H_ +#endif // CHROME_COMMON_SOCKET_STREAM_DISPATCHER_H_ diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc index d22f52a0..2a62005 100644 --- a/chrome/renderer/render_thread.cc +++ b/chrome/renderer/render_thread.cc @@ -53,7 +53,6 @@ #include "chrome/renderer/render_view_visitor.h" #include "chrome/renderer/renderer_webkitclient_impl.h" #include "chrome/renderer/renderer_web_database_observer.h" -#include "chrome/renderer/socket_stream_dispatcher.h" #include "chrome/renderer/spellchecker/spellcheck.h" #include "chrome/renderer/user_script_slave.h" #include "ipc/ipc_message.h" @@ -174,7 +173,6 @@ void RenderThread::Init() { dns_master_.reset(new RenderDnsMaster()); histogram_snapshots_.reset(new RendererHistogramSnapshots()); appcache_dispatcher_.reset(new AppCacheDispatcher(this)); - socket_stream_dispatcher_.reset(new SocketStreamDispatcher()); devtools_agent_filter_ = new DevToolsAgentFilter(); AddFilter(devtools_agent_filter_.get()); db_message_filter_ = new DBMessageFilter(); @@ -319,8 +317,6 @@ void RenderThread::OnControlMessageReceived(const IPC::Message& msg) { // App cache messages are handled by a delegate. if (appcache_dispatcher_->OnMessageReceived(msg)) return; - if (socket_stream_dispatcher_->OnMessageReceived(msg)) - return; IPC_BEGIN_MESSAGE_MAP(RenderThread, msg) IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_NewTable, OnUpdateVisitedLinks) diff --git a/chrome/renderer/render_thread.h b/chrome/renderer/render_thread.h index ef880eb..f5e0d80 100644 --- a/chrome/renderer/render_thread.h +++ b/chrome/renderer/render_thread.h @@ -32,7 +32,6 @@ class RendererWebDatabaseObserver; class RendererWebKitClientImpl; class SpellCheck; class SkBitmap; -class SocketStreamDispatcher; class UserScriptSlave; class URLPattern; @@ -120,10 +119,6 @@ class RenderThread : public RenderThreadBase, return appcache_dispatcher_.get(); } - SocketStreamDispatcher* socket_stream_dispatcher() const { - return socket_stream_dispatcher_.get(); - } - SpellCheck* spellchecker() const { return spellchecker_.get(); } @@ -221,7 +216,6 @@ class RenderThread : public RenderThreadBase, scoped_ptr<RendererHistogramSnapshots> histogram_snapshots_; scoped_ptr<RendererWebKitClientImpl> webkit_client_; scoped_ptr<WebKit::WebStorageEventDispatcher> dom_storage_event_dispatcher_; - scoped_ptr<SocketStreamDispatcher> socket_stream_dispatcher_; scoped_ptr<RendererWebDatabaseObserver> renderer_web_database_observer_; scoped_ptr<SpellCheck> spellchecker_; diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc index 558589c..012a249 100644 --- a/chrome/renderer/renderer_glue.cc +++ b/chrome/renderer/renderer_glue.cc @@ -19,12 +19,12 @@ #include "base/string_util.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/render_messages.h" +#include "chrome/common/socket_stream_dispatcher.h" #include "chrome/common/url_constants.h" #include "chrome/plugin/npobject_util.h" #include "chrome/renderer/net/render_dns_master.h" #include "chrome/renderer/render_process.h" #include "chrome/renderer/render_thread.h" -#include "chrome/renderer/socket_stream_dispatcher.h" #include "googleurl/src/url_util.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" @@ -242,7 +242,7 @@ WebSocketStreamHandleBridge* WebSocketStreamHandleBridge::Create( WebKit::WebSocketStreamHandle* handle, WebSocketStreamHandleDelegate* delegate) { SocketStreamDispatcher* dispatcher = - RenderThread::current()->socket_stream_dispatcher(); + ChildThread::current()->socket_stream_dispatcher(); return dispatcher->CreateBridge(handle, delegate); } |