summaryrefslogtreecommitdiffstats
path: root/content/child
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-25 23:28:55 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-25 23:28:55 +0000
commitca405d2aa6618928e599d233adc1f937271e2b48 (patch)
tree6a63a236c184657736aad796a0a57ed688441a2e /content/child
parentaf8630b7c4464d01726af88c3e8942be27106977 (diff)
downloadchromium_src-ca405d2aa6618928e599d233adc1f937271e2b48.zip
chromium_src-ca405d2aa6618928e599d233adc1f937271e2b48.tar.gz
chromium_src-ca405d2aa6618928e599d233adc1f937271e2b48.tar.bz2
Remove usage of ChildProcess::current() and ChildThread::current() other than on the main thread. This is needed so that single process mode will work correctly with the renderer/gpu/utility threads where we will have multiple ChildProcess objects.
While doing this, I made a few cleanups: -FileSystemDispatcher was checking the return value of sending an async IPC, which always returns true. I removed the return value of those methods and updated the callers to not handle the case which never occurs. -IPCWebSocketStreamHandleBridge was posting a task to send an async message which is needless BUG=234172 R=scottmg@chromium.org Review URL: https://codereview.chromium.org/17681004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208575 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/child')
-rw-r--r--content/child/child_histogram_message_filter.cc3
-rw-r--r--content/child/child_histogram_message_filter.h3
-rw-r--r--content/child/database_util.cc35
-rw-r--r--content/child/database_util.h21
-rw-r--r--content/child/fileapi/file_system_dispatcher.cc171
-rw-r--r--content/child/fileapi/file_system_dispatcher.h32
-rw-r--r--content/child/indexed_db/indexed_db_message_filter.cc15
-rw-r--r--content/child/indexed_db/indexed_db_message_filter.h7
-rw-r--r--content/child/socket_stream_dispatcher.cc80
-rw-r--r--content/child/webmessageportchannel_impl.cc37
-rw-r--r--content/child/webmessageportchannel_impl.h12
11 files changed, 174 insertions, 242 deletions
diff --git a/content/child/child_histogram_message_filter.cc b/content/child/child_histogram_message_filter.cc
index ec145f3..057c26d 100644
--- a/content/child/child_histogram_message_filter.cc
+++ b/content/child/child_histogram_message_filter.cc
@@ -18,6 +18,7 @@ namespace content {
ChildHistogramMessageFilter::ChildHistogramMessageFilter()
: channel_(NULL),
+ io_message_loop_(ChildProcess::current()->io_message_loop_proxy()),
histogram_snapshot_manager_(this) {
}
@@ -43,7 +44,7 @@ bool ChildHistogramMessageFilter::OnMessageReceived(
}
void ChildHistogramMessageFilter::SendHistograms(int sequence_number) {
- ChildProcess::current()->io_message_loop_proxy()->PostTask(
+ io_message_loop_->PostTask(
FROM_HERE, base::Bind(&ChildHistogramMessageFilter::UploadAllHistograms,
this, sequence_number));
}
diff --git a/content/child/child_histogram_message_filter.h b/content/child/child_histogram_message_filter.h
index 8442d45..85d2e20 100644
--- a/content/child/child_histogram_message_filter.h
+++ b/content/child/child_histogram_message_filter.h
@@ -16,6 +16,7 @@
namespace base {
class HistogramSamples;
+class MessageLoopProxy;
} // namespace base
namespace content {
@@ -55,6 +56,8 @@ class ChildHistogramMessageFilter : public base::HistogramFlattener,
IPC::Channel* channel_;
+ scoped_refptr<base::MessageLoopProxy> io_message_loop_;
+
// Collection of histograms to send to the browser.
HistogramPickledList pickled_histograms_;
diff --git a/content/child/database_util.cc b/content/child/database_util.cc
index c63c4e8..e6a028b 100644
--- a/content/child/database_util.cc
+++ b/content/child/database_util.cc
@@ -4,7 +4,6 @@
#include "content/child/database_util.h"
-#include "content/child/child_thread.h"
#include "content/common/database_messages.h"
#include "ipc/ipc_sync_message_filter.h"
#include "third_party/WebKit/public/platform/WebString.h"
@@ -16,12 +15,13 @@ using WebKit::WebString;
namespace content {
Platform::FileHandle DatabaseUtil::DatabaseOpenFile(
- const WebString& vfs_file_name, int desired_flags) {
+ const WebString& vfs_file_name,
+ int desired_flags,
+ IPC::SyncMessageFilter* sync_message_filter) {
IPC::PlatformFileForTransit file_handle =
IPC::InvalidPlatformFileForTransit();
- scoped_refptr<IPC::SyncMessageFilter> filter(
- ChildThread::current()->sync_message_filter());
+ scoped_refptr<IPC::SyncMessageFilter> filter(sync_message_filter);
filter->Send(new DatabaseHostMsg_OpenFile(
vfs_file_name, desired_flags, &file_handle));
@@ -29,36 +29,39 @@ Platform::FileHandle DatabaseUtil::DatabaseOpenFile(
}
int DatabaseUtil::DatabaseDeleteFile(
- const WebString& vfs_file_name, bool sync_dir) {
+ const WebString& vfs_file_name,
+ bool sync_dir,
+ IPC::SyncMessageFilter* sync_message_filter) {
int rv = SQLITE_IOERR_DELETE;
- scoped_refptr<IPC::SyncMessageFilter> filter(
- ChildThread::current()->sync_message_filter());
+ scoped_refptr<IPC::SyncMessageFilter> filter(sync_message_filter);
filter->Send(new DatabaseHostMsg_DeleteFile(
vfs_file_name, sync_dir, &rv));
return rv;
}
-long DatabaseUtil::DatabaseGetFileAttributes(const WebString& vfs_file_name) {
+long DatabaseUtil::DatabaseGetFileAttributes(
+ const WebString& vfs_file_name,
+ IPC::SyncMessageFilter* sync_message_filter) {
int32 rv = -1;
- scoped_refptr<IPC::SyncMessageFilter> filter(
- ChildThread::current()->sync_message_filter());
+ scoped_refptr<IPC::SyncMessageFilter> filter(sync_message_filter);
filter->Send(new DatabaseHostMsg_GetFileAttributes(vfs_file_name, &rv));
return rv;
}
-long long DatabaseUtil::DatabaseGetFileSize(const WebString& vfs_file_name) {
+long long DatabaseUtil::DatabaseGetFileSize(
+ const WebString& vfs_file_name,
+ IPC::SyncMessageFilter* sync_message_filter) {
int64 rv = 0LL;
- scoped_refptr<IPC::SyncMessageFilter> filter(
- ChildThread::current()->sync_message_filter());
+ scoped_refptr<IPC::SyncMessageFilter> filter(sync_message_filter);
filter->Send(new DatabaseHostMsg_GetFileSize(vfs_file_name, &rv));
return rv;
}
long long DatabaseUtil::DatabaseGetSpaceAvailable(
- const WebString& origin_identifier) {
+ const WebString& origin_identifier,
+ IPC::SyncMessageFilter* sync_message_filter) {
int64 rv = 0LL;
- scoped_refptr<IPC::SyncMessageFilter> filter(
- ChildThread::current()->sync_message_filter());
+ scoped_refptr<IPC::SyncMessageFilter> filter(sync_message_filter);
filter->Send(new DatabaseHostMsg_GetSpaceAvailable(origin_identifier.utf8(),
&rv));
return rv;
diff --git a/content/child/database_util.h b/content/child/database_util.h
index 7508ca5..75bcd20 100644
--- a/content/child/database_util.h
+++ b/content/child/database_util.h
@@ -7,21 +7,32 @@
#include "webkit/glue/webkitplatformsupport_impl.h"
+namespace IPC {
+class SyncMessageFilter;
+}
+
namespace content {
// A class of utility functions used by RendererWebKitPlatformSupportImpl and
// WorkerWebKitPlatformSupportImpl to handle database file accesses.
class DatabaseUtil {
public:
static WebKit::Platform::FileHandle DatabaseOpenFile(
- const WebKit::WebString& vfs_file_name, int desired_flags);
+ const WebKit::WebString& vfs_file_name,
+ int desired_flags,
+ IPC::SyncMessageFilter* sync_message_filter);
static int DatabaseDeleteFile(
- const WebKit::WebString& vfs_file_name, bool sync_dir);
+ const WebKit::WebString& vfs_file_name,
+ bool sync_dir,
+ IPC::SyncMessageFilter* sync_message_filter);
static long DatabaseGetFileAttributes(
- const WebKit::WebString& vfs_file_name);
+ const WebKit::WebString& vfs_file_name,
+ IPC::SyncMessageFilter* sync_message_filter);
static long long DatabaseGetFileSize(
- const WebKit::WebString& vfs_file_name);
+ const WebKit::WebString& vfs_file_name,
+ IPC::SyncMessageFilter* sync_message_filter);
static long long DatabaseGetSpaceAvailable(
- const WebKit::WebString& origin_identifier);
+ const WebKit::WebString& origin_identifier,
+ IPC::SyncMessageFilter* sync_message_filter);
};
} // namespace content
diff --git a/content/child/fileapi/file_system_dispatcher.cc b/content/child/fileapi/file_system_dispatcher.cc
index 31f14ec..6642a14 100644
--- a/content/child/fileapi/file_system_dispatcher.cc
+++ b/content/child/fileapi/file_system_dispatcher.cc
@@ -161,155 +161,107 @@ bool FileSystemDispatcher::OnMessageReceived(const IPC::Message& msg) {
return handled;
}
-bool FileSystemDispatcher::OpenFileSystem(
+void FileSystemDispatcher::OpenFileSystem(
const GURL& origin_url, fileapi::FileSystemType type,
long long size, bool create,
const OpenFileSystemCallback& success_callback,
const StatusCallback& error_callback) {
int request_id = dispatchers_.Add(
CallbackDispatcher::Create(success_callback, error_callback));
- if (!ChildThread::current()->Send(new FileSystemHostMsg_Open(
- request_id, origin_url, type, size, create))) {
- dispatchers_.Remove(request_id); // destroys |dispatcher|
- return false;
- }
-
- return true;
+ ChildThread::current()->Send(new FileSystemHostMsg_Open(
+ request_id, origin_url, type, size, create));
}
-bool FileSystemDispatcher::DeleteFileSystem(
+void FileSystemDispatcher::DeleteFileSystem(
const GURL& origin_url,
fileapi::FileSystemType type,
const StatusCallback& callback) {
int request_id = dispatchers_.Add(CallbackDispatcher::Create(callback));
- if (!ChildThread::current()->Send(new FileSystemHostMsg_DeleteFileSystem(
- request_id, origin_url, type))) {
- dispatchers_.Remove(request_id);
- return false;
- }
- return true;
+ ChildThread::current()->Send(new FileSystemHostMsg_DeleteFileSystem(
+ request_id, origin_url, type));
}
-bool FileSystemDispatcher::Move(
+void FileSystemDispatcher::Move(
const GURL& src_path,
const GURL& dest_path,
const StatusCallback& callback) {
int request_id = dispatchers_.Add(CallbackDispatcher::Create(callback));
- if (!ChildThread::current()->Send(new FileSystemHostMsg_Move(
- request_id, src_path, dest_path))) {
- dispatchers_.Remove(request_id); // destroys |dispatcher|
- return false;
- }
-
- return true;
+ ChildThread::current()->Send(new FileSystemHostMsg_Move(
+ request_id, src_path, dest_path));
}
-bool FileSystemDispatcher::Copy(
+void FileSystemDispatcher::Copy(
const GURL& src_path,
const GURL& dest_path,
const StatusCallback& callback) {
int request_id = dispatchers_.Add(CallbackDispatcher::Create(callback));
- if (!ChildThread::current()->Send(new FileSystemHostMsg_Copy(
- request_id, src_path, dest_path))) {
- dispatchers_.Remove(request_id); // destroys |dispatcher|
- return false;
- }
-
- return true;
+ ChildThread::current()->Send(new FileSystemHostMsg_Copy(
+ request_id, src_path, dest_path));
}
-bool FileSystemDispatcher::Remove(
+void FileSystemDispatcher::Remove(
const GURL& path,
bool recursive,
const StatusCallback& callback) {
int request_id = dispatchers_.Add(CallbackDispatcher::Create(callback));
- if (!ChildThread::current()->Send(
- new FileSystemMsg_Remove(request_id, path, recursive))) {
- dispatchers_.Remove(request_id); // destroys |dispatcher|
- return false;
- }
-
- return true;
+ ChildThread::current()->Send(
+ new FileSystemMsg_Remove(request_id, path, recursive));
}
-bool FileSystemDispatcher::ReadMetadata(
+void FileSystemDispatcher::ReadMetadata(
const GURL& path,
const MetadataCallback& success_callback,
const StatusCallback& error_callback) {
int request_id = dispatchers_.Add(
CallbackDispatcher::Create(success_callback, error_callback));
- if (!ChildThread::current()->Send(
- new FileSystemHostMsg_ReadMetadata(request_id, path))) {
- dispatchers_.Remove(request_id); // destroys |dispatcher|
- return false;
- }
-
- return true;
+ ChildThread::current()->Send(
+ new FileSystemHostMsg_ReadMetadata(request_id, path));
}
-bool FileSystemDispatcher::Create(
+void FileSystemDispatcher::Create(
const GURL& path,
bool exclusive,
bool is_directory,
bool recursive,
const StatusCallback& callback) {
int request_id = dispatchers_.Add(CallbackDispatcher::Create(callback));
- if (!ChildThread::current()->Send(new FileSystemHostMsg_Create(
- request_id, path, exclusive, is_directory, recursive))) {
- dispatchers_.Remove(request_id); // destroys |dispatcher|
- return false;
- }
-
- return true;
+ ChildThread::current()->Send(new FileSystemHostMsg_Create(
+ request_id, path, exclusive, is_directory, recursive));
}
-bool FileSystemDispatcher::Exists(
+void FileSystemDispatcher::Exists(
const GURL& path,
bool is_directory,
const StatusCallback& callback) {
int request_id = dispatchers_.Add(CallbackDispatcher::Create(callback));
- if (!ChildThread::current()->Send(
- new FileSystemHostMsg_Exists(request_id, path, is_directory))) {
- dispatchers_.Remove(request_id); // destroys |dispatcher|
- return false;
- }
-
- return true;
+ ChildThread::current()->Send(
+ new FileSystemHostMsg_Exists(request_id, path, is_directory));
}
-bool FileSystemDispatcher::ReadDirectory(
+void FileSystemDispatcher::ReadDirectory(
const GURL& path,
const ReadDirectoryCallback& success_callback,
const StatusCallback& error_callback) {
int request_id = dispatchers_.Add(
CallbackDispatcher::Create(success_callback, error_callback));
- if (!ChildThread::current()->Send(
- new FileSystemHostMsg_ReadDirectory(request_id, path))) {
- dispatchers_.Remove(request_id); // destroys |dispatcher|
- return false;
- }
-
- return true;
+ ChildThread::current()->Send(
+ new FileSystemHostMsg_ReadDirectory(request_id, path));
}
-bool FileSystemDispatcher::Truncate(
+void FileSystemDispatcher::Truncate(
const GURL& path,
int64 offset,
int* request_id_out,
const StatusCallback& callback) {
int request_id = dispatchers_.Add(CallbackDispatcher::Create(callback));
- if (!ChildThread::current()->Send(
- new FileSystemHostMsg_Truncate(request_id, path, offset))) {
- dispatchers_.Remove(request_id); // destroys |dispatcher|
- return false;
- }
+ ChildThread::current()->Send(
+ new FileSystemHostMsg_Truncate(request_id, path, offset));
if (request_id_out)
*request_id_out = request_id;
- return true;
}
-bool FileSystemDispatcher::Write(
+void FileSystemDispatcher::Write(
const GURL& path,
const GURL& blob_url,
int64 offset,
@@ -318,81 +270,58 @@ bool FileSystemDispatcher::Write(
const StatusCallback& error_callback) {
int request_id = dispatchers_.Add(
CallbackDispatcher::Create(success_callback, error_callback));
- if (!ChildThread::current()->Send(
- new FileSystemHostMsg_Write(request_id, path, blob_url, offset))) {
- dispatchers_.Remove(request_id); // destroys |dispatcher|
- return false;
- }
+ ChildThread::current()->Send(
+ new FileSystemHostMsg_Write(request_id, path, blob_url, offset));
if (request_id_out)
*request_id_out = request_id;
- return true;
}
-bool FileSystemDispatcher::Cancel(
+void FileSystemDispatcher::Cancel(
int request_id_to_cancel,
const StatusCallback& callback) {
int request_id = dispatchers_.Add(CallbackDispatcher::Create(callback));
- if (!ChildThread::current()->Send(new FileSystemHostMsg_CancelWrite(
- request_id, request_id_to_cancel))) {
- dispatchers_.Remove(request_id); // destroys |dispatcher|
- return false;
- }
-
- return true;
+ ChildThread::current()->Send(new FileSystemHostMsg_CancelWrite(
+ request_id, request_id_to_cancel));
}
-bool FileSystemDispatcher::TouchFile(
+void FileSystemDispatcher::TouchFile(
const GURL& path,
const base::Time& last_access_time,
const base::Time& last_modified_time,
const StatusCallback& callback) {
int request_id = dispatchers_.Add(CallbackDispatcher::Create(callback));
- if (!ChildThread::current()->Send(
- new FileSystemHostMsg_TouchFile(
- request_id, path, last_access_time, last_modified_time))) {
- dispatchers_.Remove(request_id); // destroys |dispatcher|
- return false;
- }
-
- return true;
+ ChildThread::current()->Send(
+ new FileSystemHostMsg_TouchFile(
+ request_id, path, last_access_time, last_modified_time));
}
-bool FileSystemDispatcher::OpenFile(
+void FileSystemDispatcher::OpenFile(
const GURL& file_path,
int file_flags,
const OpenFileCallback& success_callback,
const StatusCallback& error_callback) {
int request_id = dispatchers_.Add(
CallbackDispatcher::Create(success_callback, error_callback));
- if (!ChildThread::current()->Send(
- new FileSystemHostMsg_OpenFile(
- request_id, file_path, file_flags))) {
- dispatchers_.Remove(request_id); // destroys |dispatcher|
- return false;
- }
-
- return true;
+ ChildThread::current()->Send(
+ new FileSystemHostMsg_OpenFile(
+ request_id, file_path, file_flags));
}
-bool FileSystemDispatcher::NotifyCloseFile(int file_open_id) {
- return ChildThread::current()->Send(
+void FileSystemDispatcher::NotifyCloseFile(int file_open_id) {
+ ChildThread::current()->Send(
new FileSystemHostMsg_NotifyCloseFile(file_open_id));
}
-bool FileSystemDispatcher::CreateSnapshotFile(
+void FileSystemDispatcher::CreateSnapshotFile(
const GURL& file_path,
const CreateSnapshotFileCallback& success_callback,
const StatusCallback& error_callback) {
int request_id = dispatchers_.Add(
CallbackDispatcher::Create(success_callback, error_callback));
- if (!ChildThread::current()->Send(
- new FileSystemHostMsg_CreateSnapshotFile(
- request_id, file_path))) {
- dispatchers_.Remove(request_id); // destroys |dispatcher|
- return false;
- }
- return true;
+ ChildThread::current()->Send(
+ new FileSystemHostMsg_CreateSnapshotFile(
+ request_id, file_path));
}
void FileSystemDispatcher::OnDidOpenFileSystem(int request_id,
diff --git a/content/child/fileapi/file_system_dispatcher.h b/content/child/fileapi/file_system_dispatcher.h
index 10e0438..1e155db 100644
--- a/content/child/fileapi/file_system_dispatcher.h
+++ b/content/child/fileapi/file_system_dispatcher.h
@@ -61,66 +61,66 @@ class FileSystemDispatcher : public IPC::Listener {
// IPC::Listener implementation.
virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
- bool OpenFileSystem(const GURL& origin_url,
+ void OpenFileSystem(const GURL& origin_url,
fileapi::FileSystemType type,
long long size,
bool create,
const OpenFileSystemCallback& success_callback,
const StatusCallback& error_callback);
- bool DeleteFileSystem(const GURL& origin_url,
+ void DeleteFileSystem(const GURL& origin_url,
fileapi::FileSystemType type,
const StatusCallback& callback);
- bool Move(const GURL& src_path,
+ void Move(const GURL& src_path,
const GURL& dest_path,
const StatusCallback& callback);
- bool Copy(const GURL& src_path,
+ void Copy(const GURL& src_path,
const GURL& dest_path,
const StatusCallback& callback);
- bool Remove(const GURL& path,
+ void Remove(const GURL& path,
bool recursive,
const StatusCallback& callback);
- bool ReadMetadata(const GURL& path,
+ void ReadMetadata(const GURL& path,
const MetadataCallback& success_callback,
const StatusCallback& error_callback);
- bool Create(const GURL& path,
+ void Create(const GURL& path,
bool exclusive,
bool is_directory,
bool recursive,
const StatusCallback& callback);
- bool Exists(const GURL& path,
+ void Exists(const GURL& path,
bool for_directory,
const StatusCallback& callback);
- bool ReadDirectory(const GURL& path,
+ void ReadDirectory(const GURL& path,
const ReadDirectoryCallback& success_callback,
const StatusCallback& error_callback);
- bool Truncate(const GURL& path,
+ void Truncate(const GURL& path,
int64 offset,
int* request_id_out,
const StatusCallback& callback);
- bool Write(const GURL& path,
+ void Write(const GURL& path,
const GURL& blob_url,
int64 offset,
int* request_id_out,
const WriteCallback& success_callback,
const StatusCallback& error_callback);
- bool Cancel(int request_id_to_cancel,
+ void Cancel(int request_id_to_cancel,
const StatusCallback& callback);
- bool TouchFile(const GURL& file_path,
+ void TouchFile(const GURL& file_path,
const base::Time& last_access_time,
const base::Time& last_modified_time,
const StatusCallback& callback);
// This returns a raw open PlatformFile, unlike the above, which are
// self-contained operations.
- bool OpenFile(const GURL& file_path,
+ void OpenFile(const GURL& file_path,
int file_flags, // passed to FileUtilProxy::CreateOrOpen
const OpenFileCallback& success_callback,
const StatusCallback& error_callback);
// This must be paired with OpenFile, and called after finished using the
// raw PlatformFile returned from OpenFile.
- bool NotifyCloseFile(int file_open_id);
+ void NotifyCloseFile(int file_open_id);
- bool CreateSnapshotFile(const GURL& file_path,
+ void CreateSnapshotFile(const GURL& file_path,
const CreateSnapshotFileCallback& success_callback,
const StatusCallback& error_callback);
diff --git a/content/child/indexed_db/indexed_db_message_filter.cc b/content/child/indexed_db/indexed_db_message_filter.cc
index 11930b01..4e44b11 100644
--- a/content/child/indexed_db/indexed_db_message_filter.cc
+++ b/content/child/indexed_db/indexed_db_message_filter.cc
@@ -8,7 +8,6 @@
#include "base/location.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/pickle.h"
-#include "content/child/child_thread.h"
#include "content/child/indexed_db/indexed_db_dispatcher.h"
#include "content/common/indexed_db/indexed_db_messages.h"
#include "webkit/child/worker_task_runner.h"
@@ -17,8 +16,10 @@ using webkit_glue::WorkerTaskRunner;
namespace content {
-IndexedDBMessageFilter::IndexedDBMessageFilter() :
- main_thread_loop_proxy_(base::MessageLoopProxy::current()) {
+IndexedDBMessageFilter::IndexedDBMessageFilter(
+ IPC::SyncMessageFilter* sync_message_filter)
+ : main_thread_loop_proxy_(base::MessageLoopProxy::current()),
+ sync_message_filter_(sync_message_filter) {
}
bool IndexedDBMessageFilter::OnMessageReceived(const IPC::Message& msg) {
@@ -62,17 +63,13 @@ void IndexedDBMessageFilter::OnStaleSuccessIDBDatabase(
int32 ipc_database_callbacks_id,
int32 ipc_database_id,
const IndexedDBDatabaseMetadata& idb_metadata) {
- scoped_refptr<IPC::SyncMessageFilter> filter(
- ChildThread::current()->sync_message_filter());
- filter->Send(
+ sync_message_filter_->Send(
new IndexedDBHostMsg_DatabaseClose(ipc_database_id));
}
void IndexedDBMessageFilter::OnStaleUpgradeNeeded(
const IndexedDBMsg_CallbacksUpgradeNeeded_Params& p) {
- scoped_refptr<IPC::SyncMessageFilter> filter(
- ChildThread::current()->sync_message_filter());
- filter->Send(
+ sync_message_filter_->Send(
new IndexedDBHostMsg_DatabaseClose(p.ipc_database_id));
}
diff --git a/content/child/indexed_db/indexed_db_message_filter.h b/content/child/indexed_db/indexed_db_message_filter.h
index 04708d3..43f9413 100644
--- a/content/child/indexed_db/indexed_db_message_filter.h
+++ b/content/child/indexed_db/indexed_db_message_filter.h
@@ -14,12 +14,16 @@ namespace base {
class MessageLoopProxy;
} // namespace base
+namespace IPC {
+class SyncMessageFilter;
+}
+
namespace content {
class IndexedDBDispatcher;
class IndexedDBMessageFilter : public IPC::ChannelProxy::MessageFilter {
public:
- IndexedDBMessageFilter();
+ explicit IndexedDBMessageFilter(IPC::SyncMessageFilter* sync_message_filter);
// IPC::Listener implementation.
virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
@@ -38,6 +42,7 @@ class IndexedDBMessageFilter : public IPC::ChannelProxy::MessageFilter {
void OnStaleUpgradeNeeded(const IndexedDBMsg_CallbacksUpgradeNeeded_Params&);
scoped_refptr<base::MessageLoopProxy> main_thread_loop_proxy_;
+ scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_;
DISALLOW_COPY_AND_ASSIGN(IndexedDBMessageFilter);
};
diff --git a/content/child/socket_stream_dispatcher.cc b/content/child/socket_stream_dispatcher.cc
index dc3da14..c533cba 100644
--- a/content/child/socket_stream_dispatcher.cc
+++ b/content/child/socket_stream_dispatcher.cc
@@ -30,11 +30,9 @@ class IPCWebSocketStreamHandleBridge
: public webkit_glue::WebSocketStreamHandleBridge {
public:
IPCWebSocketStreamHandleBridge(
- ChildThread* child_thread,
WebKit::WebSocketStreamHandle* handle,
webkit_glue::WebSocketStreamHandleDelegate* delegate)
: socket_id_(kNoSocketId),
- child_thread_(child_thread),
handle_(handle),
delegate_(delegate) {}
@@ -56,14 +54,10 @@ class IPCWebSocketStreamHandleBridge
private:
virtual ~IPCWebSocketStreamHandleBridge();
- void DoConnect(const GURL& url);
- void DoClose();
-
// The ID for this bridge and corresponding SocketStream instance in the
// browser process.
int socket_id_;
- ChildThread* child_thread_;
WebKit::WebSocketStreamHandle* handle_;
webkit_glue::WebSocketStreamHandleDelegate* delegate_;
@@ -89,40 +83,46 @@ IPCWebSocketStreamHandleBridge::~IPCWebSocketStreamHandleBridge() {
if (socket_id_ == kNoSocketId)
return;
- child_thread_->Send(new SocketStreamHostMsg_Close(socket_id_));
+ ChildThread::current()->Send(new SocketStreamHostMsg_Close(socket_id_));
socket_id_ = kNoSocketId;
}
void IPCWebSocketStreamHandleBridge::Connect(const GURL& url) {
- DCHECK(child_thread_);
DVLOG(1) << "Bridge (" << this << ") Connect (url=" << url << ")";
- child_thread_->message_loop()->PostTask(
- FROM_HERE,
- base::Bind(&IPCWebSocketStreamHandleBridge::DoConnect, this, url));
+ DCHECK_EQ(socket_id_, kNoSocketId);
+ if (delegate_)
+ delegate_->WillOpenStream(handle_, url);
+
+ socket_id_ = all_bridges.Get().Add(this);
+ DCHECK_NE(socket_id_, kNoSocketId);
+ int render_view_id = MSG_ROUTING_NONE;
+ const SocketStreamHandleData* data =
+ SocketStreamHandleData::ForHandle(handle_);
+ if (data)
+ render_view_id = data->render_view_id();
+ AddRef(); // Released in OnClosed().
+ ChildThread::current()->Send(
+ new SocketStreamHostMsg_Connect(render_view_id, url, socket_id_));
+ DVLOG(1) << "Bridge #" << socket_id_ << " sent IPC Connect";
+ // TODO(ukai): timeout to OnConnected.
}
-bool IPCWebSocketStreamHandleBridge::Send(
- const std::vector<char>& data) {
+bool IPCWebSocketStreamHandleBridge::Send(const std::vector<char>& data) {
DVLOG(1) << "Bridge #" << socket_id_ << " Send (" << data.size()
<< " bytes)";
- if (child_thread_->Send(
- new SocketStreamHostMsg_SendData(socket_id_, data))) {
- if (delegate_)
- delegate_->WillSendData(handle_, &data[0], data.size());
- return true;
- }
- return false;
+ ChildThread::current()->Send(
+ new SocketStreamHostMsg_SendData(socket_id_, data));
+ if (delegate_)
+ delegate_->WillSendData(handle_, &data[0], data.size());
+ return true;
}
void IPCWebSocketStreamHandleBridge::Close() {
DVLOG(1) << "Bridge #" << socket_id_ << " Close";
- AddRef(); // Released in DoClose().
- child_thread_->message_loop()->PostTask(
- FROM_HERE,
- base::Bind(&IPCWebSocketStreamHandleBridge::DoClose, this));
+ ChildThread::current()->Send(new SocketStreamHostMsg_Close(socket_id_));
}
void IPCWebSocketStreamHandleBridge::OnConnected(int max_pending_send_allowed) {
@@ -171,35 +171,6 @@ void IPCWebSocketStreamHandleBridge::OnFailed(int error_code,
delegate_->DidFail(handle_, error_code, ASCIIToUTF16(error_msg));
}
-void IPCWebSocketStreamHandleBridge::DoConnect(const GURL& url) {
- DCHECK(child_thread_);
- DCHECK_EQ(socket_id_, kNoSocketId);
- if (delegate_)
- delegate_->WillOpenStream(handle_, url);
-
- socket_id_ = all_bridges.Get().Add(this);
- DCHECK_NE(socket_id_, kNoSocketId);
- int render_view_id = MSG_ROUTING_NONE;
- const SocketStreamHandleData* data =
- SocketStreamHandleData::ForHandle(handle_);
- if (data)
- render_view_id = data->render_view_id();
- AddRef(); // Released in OnClosed().
- if (child_thread_->Send(
- new SocketStreamHostMsg_Connect(render_view_id, url, socket_id_))) {
- DVLOG(1) << "Bridge #" << socket_id_ << " sent IPC Connect";
- // TODO(ukai): timeout to OnConnected.
- } else {
- DLOG(ERROR) << "Bridge #" << socket_id_ << " failed to send IPC Connect";
- OnClosed();
- }
-}
-
-void IPCWebSocketStreamHandleBridge::DoClose() {
- child_thread_->Send(new SocketStreamHostMsg_Close(socket_id_));
- Release();
-}
-
SocketStreamDispatcher::SocketStreamDispatcher() {
}
@@ -208,8 +179,7 @@ webkit_glue::WebSocketStreamHandleBridge*
SocketStreamDispatcher::CreateBridge(
WebKit::WebSocketStreamHandle* handle,
webkit_glue::WebSocketStreamHandleDelegate* delegate) {
- return new IPCWebSocketStreamHandleBridge(
- ChildThread::current(), handle, delegate);
+ return new IPCWebSocketStreamHandleBridge(handle, delegate);
}
bool SocketStreamDispatcher::OnMessageReceived(const IPC::Message& msg) {
diff --git a/content/child/webmessageportchannel_impl.cc b/content/child/webmessageportchannel_impl.cc
index 98048c1..d082434 100644
--- a/content/child/webmessageportchannel_impl.cc
+++ b/content/child/webmessageportchannel_impl.cc
@@ -5,6 +5,7 @@
#include "content/child/webmessageportchannel_impl.h"
#include "base/bind.h"
+#include "base/message_loop/message_loop_proxy.h"
#include "content/child/child_process.h"
#include "content/child/child_thread.h"
#include "content/common/worker_messages.h"
@@ -18,20 +19,24 @@ using WebKit::WebString;
namespace content {
-WebMessagePortChannelImpl::WebMessagePortChannelImpl()
+WebMessagePortChannelImpl::WebMessagePortChannelImpl(
+ base::MessageLoopProxy* child_thread_loop)
: client_(NULL),
route_id_(MSG_ROUTING_NONE),
- message_port_id_(MSG_ROUTING_NONE) {
+ message_port_id_(MSG_ROUTING_NONE),
+ child_thread_loop_(child_thread_loop) {
AddRef();
Init();
}
WebMessagePortChannelImpl::WebMessagePortChannelImpl(
int route_id,
- int message_port_id)
+ int message_port_id,
+ base::MessageLoopProxy* child_thread_loop)
: client_(NULL),
route_id_(route_id),
- message_port_id_(message_port_id) {
+ message_port_id_(message_port_id),
+ child_thread_loop_(child_thread_loop) {
AddRef();
Init();
}
@@ -65,7 +70,7 @@ void WebMessagePortChannelImpl::destroy() {
// Release the object on the main thread, since the destructor might want to
// send an IPC, and that has to happen on the main thread.
- ChildThread::current()->message_loop()->ReleaseSoon(FROM_HERE, this);
+ child_thread_loop_->ReleaseSoon(FROM_HERE, this);
}
void WebMessagePortChannelImpl::entangle(WebMessagePortChannel* channel) {
@@ -80,8 +85,8 @@ void WebMessagePortChannelImpl::entangle(WebMessagePortChannel* channel) {
void WebMessagePortChannelImpl::postMessage(
const WebString& message,
WebMessagePortChannelArray* channels) {
- if (base::MessageLoop::current() != ChildThread::current()->message_loop()) {
- ChildThread::current()->message_loop()->PostTask(
+ if (!child_thread_loop_->BelongsToCurrentThread()) {
+ child_thread_loop_->PostTask(
FROM_HERE,
base::Bind(
&WebMessagePortChannelImpl::postMessage, this, message, channels));
@@ -127,8 +132,8 @@ bool WebMessagePortChannelImpl::tryGetMessage(
}
void WebMessagePortChannelImpl::Init() {
- if (base::MessageLoop::current() != ChildThread::current()->message_loop()) {
- ChildThread::current()->message_loop()->PostTask(
+ if (!child_thread_loop_->BelongsToCurrentThread()) {
+ child_thread_loop_->PostTask(
FROM_HERE, base::Bind(&WebMessagePortChannelImpl::Init, this));
return;
}
@@ -144,8 +149,8 @@ void WebMessagePortChannelImpl::Init() {
void WebMessagePortChannelImpl::Entangle(
scoped_refptr<WebMessagePortChannelImpl> channel) {
- if (base::MessageLoop::current() != ChildThread::current()->message_loop()) {
- ChildThread::current()->message_loop()->PostTask(
+ if (!child_thread_loop_->BelongsToCurrentThread()) {
+ child_thread_loop_->PostTask(
FROM_HERE,
base::Bind(&WebMessagePortChannelImpl::Entangle, this, channel));
return;
@@ -156,8 +161,8 @@ void WebMessagePortChannelImpl::Entangle(
}
void WebMessagePortChannelImpl::QueueMessages() {
- if (base::MessageLoop::current() != ChildThread::current()->message_loop()) {
- ChildThread::current()->message_loop()->PostTask(
+ if (!child_thread_loop_->BelongsToCurrentThread()) {
+ child_thread_loop_->PostTask(
FROM_HERE, base::Bind(&WebMessagePortChannelImpl::QueueMessages, this));
return;
}
@@ -175,9 +180,9 @@ void WebMessagePortChannelImpl::QueueMessages() {
}
void WebMessagePortChannelImpl::Send(IPC::Message* message) {
- if (base::MessageLoop::current() != ChildThread::current()->message_loop()) {
+ if (!child_thread_loop_->BelongsToCurrentThread()) {
DCHECK(!message->is_sync());
- ChildThread::current()->message_loop()->PostTask(
+ child_thread_loop_->PostTask(
FROM_HERE,
base::Bind(&WebMessagePortChannelImpl::Send, this, message));
return;
@@ -207,7 +212,7 @@ void WebMessagePortChannelImpl::OnMessage(
msg.ports.resize(sent_message_port_ids.size());
for (size_t i = 0; i < sent_message_port_ids.size(); ++i) {
msg.ports[i] = new WebMessagePortChannelImpl(
- new_routing_ids[i], sent_message_port_ids[i]);
+ new_routing_ids[i], sent_message_port_ids[i], child_thread_loop_);
}
}
diff --git a/content/child/webmessageportchannel_impl.h b/content/child/webmessageportchannel_impl.h
index 57e79a3..8440539 100644
--- a/content/child/webmessageportchannel_impl.h
+++ b/content/child/webmessageportchannel_impl.h
@@ -15,7 +15,12 @@
#include "ipc/ipc_listener.h"
#include "third_party/WebKit/public/platform/WebMessagePortChannel.h"
+namespace base {
+class MessageLoopProxy;
+}
+
namespace content {
+class ChildThread;
// This is thread safe.
class WebMessagePortChannelImpl
@@ -23,8 +28,10 @@ class WebMessagePortChannelImpl
public IPC::Listener,
public base::RefCountedThreadSafe<WebMessagePortChannelImpl> {
public:
- WebMessagePortChannelImpl();
- WebMessagePortChannelImpl(int route_id, int message_port_id);
+ explicit WebMessagePortChannelImpl(base::MessageLoopProxy* child_thread_loop);
+ WebMessagePortChannelImpl(int route_id,
+ int message_port_id,
+ base::MessageLoopProxy* child_thread_loop);
// Queues received and incoming messages until there are no more in-flight
// messages, then sends all of them to the browser process.
@@ -72,6 +79,7 @@ class WebMessagePortChannelImpl
int route_id_; // The routing id for this object.
int message_port_id_; // A globally unique identifier for this message port.
+ scoped_refptr<base::MessageLoopProxy> child_thread_loop_;
DISALLOW_COPY_AND_ASSIGN(WebMessagePortChannelImpl);
};