summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/browser_process_impl.cc3
-rw-r--r--chrome/browser/download/download_request_manager.cc28
-rw-r--r--chrome/browser/download/download_request_manager.h8
-rw-r--r--chrome/browser/download/download_request_manager_unittest.cc8
-rw-r--r--chrome/browser/extensions/user_script_listener_unittest.cc28
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_observer.cc11
-rw-r--r--chrome/browser/renderer_host/cross_site_resource_handler.cc19
-rw-r--r--chrome/browser/renderer_host/database_dispatcher_host.cc85
-rw-r--r--chrome/browser/renderer_host/database_dispatcher_host.h14
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host.cc8
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host.h13
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc1
-rw-r--r--chrome/browser/renderer_host/safe_browsing_resource_handler.cc4
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_service.cc8
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_service.h1
-rw-r--r--chrome/browser/utility_process_host_unittest.cc7
-rw-r--r--chrome/common/child_process_host.cc9
17 files changed, 107 insertions, 148 deletions
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index af54bb5..05d4299 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -298,8 +298,7 @@ void BrowserProcessImpl::CreateResourceDispatcherHost() {
resource_dispatcher_host_.get() == NULL);
created_resource_dispatcher_host_ = true;
- resource_dispatcher_host_.reset(
- new ResourceDispatcherHost(io_thread()->message_loop()));
+ resource_dispatcher_host_.reset(new ResourceDispatcherHost());
resource_dispatcher_host_->Initialize();
}
diff --git a/chrome/browser/download/download_request_manager.cc b/chrome/browser/download/download_request_manager.cc
index 98a20ff..bcb4214 100644
--- a/chrome/browser/download/download_request_manager.cc
+++ b/chrome/browser/download/download_request_manager.cc
@@ -4,8 +4,7 @@
#include "chrome/browser/download/download_request_manager.h"
-#include "base/message_loop.h"
-#include "base/thread.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/download/download_request_infobar_delegate.h"
#include "chrome/browser/tab_contents/navigation_controller.h"
#include "chrome/browser/tab_contents/navigation_entry.h"
@@ -152,10 +151,7 @@ void DownloadRequestManager::TabDownloadState::NotifyCallbacks(bool allow) {
// DownloadRequestManager ------------------------------------------------------
-DownloadRequestManager::DownloadRequestManager(MessageLoop* io_loop,
- MessageLoop* ui_loop)
- : io_loop_(io_loop),
- ui_loop_(ui_loop) {
+DownloadRequestManager::DownloadRequestManager() {
}
DownloadRequestManager::~DownloadRequestManager() {
@@ -175,8 +171,9 @@ void DownloadRequestManager::CanDownloadOnIOThread(int render_process_host_id,
Callback* callback) {
// This is invoked on the IO thread. Schedule the task to run on the UI
// thread so that we can query UI state.
- DCHECK(!io_loop_ || io_loop_ == MessageLoop::current());
- ui_loop_->PostTask(FROM_HERE,
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
NewRunnableMethod(this, &DownloadRequestManager::CanDownload,
render_process_host_id, render_view_id, callback));
}
@@ -215,7 +212,7 @@ DownloadRequestManager::TabDownloadState* DownloadRequestManager::
void DownloadRequestManager::CanDownload(int render_process_host_id,
int render_view_id,
Callback* callback) {
- DCHECK(!ui_loop_ || MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
TabContents* originating_tab =
tab_util::GetTabContentsByID(render_process_host_id, render_view_id);
@@ -265,18 +262,15 @@ void DownloadRequestManager::CanDownloadImpl(
void DownloadRequestManager::ScheduleNotification(Callback* callback,
bool allow) {
- if (io_loop_) {
- io_loop_->PostTask(FROM_HERE,
- NewRunnableMethod(this, &DownloadRequestManager::NotifyCallback,
- callback, allow));
- } else {
- NotifyCallback(callback, allow);
- }
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ this, &DownloadRequestManager::NotifyCallback, callback, allow));
}
void DownloadRequestManager::NotifyCallback(Callback* callback, bool allow) {
// We better be on the IO thread now.
- DCHECK(!io_loop_ || MessageLoop::current() == io_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
if (allow)
callback->ContinueDownload();
else
diff --git a/chrome/browser/download/download_request_manager.h b/chrome/browser/download/download_request_manager.h
index 8844de7..8e120bb 100644
--- a/chrome/browser/download/download_request_manager.h
+++ b/chrome/browser/download/download_request_manager.h
@@ -14,7 +14,6 @@
#include "chrome/common/notification_registrar.h"
class DownloadRequestInfoBarDelegate;
-class MessageLoop;
class NavigationController;
class TabContents;
@@ -148,7 +147,7 @@ class DownloadRequestManager :
DISALLOW_COPY_AND_ASSIGN(TabDownloadState);
};
- DownloadRequestManager(MessageLoop* io_loop, MessageLoop* ui_loop);
+ DownloadRequestManager();
~DownloadRequestManager();
// Returns the download status for a page. This does not change the state in
@@ -215,11 +214,6 @@ class DownloadRequestManager :
// ALLOW_ONE_DOWNLOAD.
void Remove(TabDownloadState* state);
- // Two threads we use. NULL during testing, in which case messages are
- // dispatched immediately.
- MessageLoop* io_loop_;
- MessageLoop* ui_loop_;
-
// Maps from tab to download state. The download state for a tab only exists
// if the state is other than ALLOW_ONE_DOWNLOAD. Similarly once the state
// transitions from anything but ALLOW_ONE_DOWNLOAD back to ALLOW_ONE_DOWNLOAD
diff --git a/chrome/browser/download/download_request_manager_unittest.cc b/chrome/browser/download/download_request_manager_unittest.cc
index a9f6382..c55bea4 100644
--- a/chrome/browser/download/download_request_manager_unittest.cc
+++ b/chrome/browser/download/download_request_manager_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/download/download_request_manager.h"
#include "chrome/browser/renderer_host/test/test_render_view_host.h"
#include "chrome/browser/tab_contents/navigation_controller.h"
@@ -12,13 +13,15 @@ class DownloadRequestManagerTest
: public RenderViewHostTestHarness,
public DownloadRequestManager::Callback {
public:
+ DownloadRequestManagerTest() : io_thread_(ChromeThread::IO, &message_loop_) {}
+
virtual void SetUp() {
RenderViewHostTestHarness::SetUp();
allow_download_ = true;
ask_allow_count_ = cancel_count_ = continue_count_ = 0;
- download_request_manager_ = new DownloadRequestManager(NULL, NULL);
+ download_request_manager_ = new DownloadRequestManager();
test_delegate_.reset(new DownloadRequestManagerTestDelegate(this));
DownloadRequestManager::SetTestingDelegate(test_delegate_.get());
}
@@ -39,6 +42,7 @@ class DownloadRequestManagerTest
void CanDownload() {
download_request_manager_->CanDownloadImpl(
controller().tab_contents(), this);
+ message_loop_.RunAllPending();
}
bool ShouldAllowDownload() {
@@ -75,6 +79,8 @@ class DownloadRequestManagerTest
// Number of times ShouldAllowDownload was invoked.
int ask_allow_count_;
+
+ ChromeThread io_thread_;
};
TEST_F(DownloadRequestManagerTest, Allow) {
diff --git a/chrome/browser/extensions/user_script_listener_unittest.cc b/chrome/browser/extensions/user_script_listener_unittest.cc
index c644f1f..14a9d0e 100644
--- a/chrome/browser/extensions/user_script_listener_unittest.cc
+++ b/chrome/browser/extensions/user_script_listener_unittest.cc
@@ -65,11 +65,8 @@ class ResourceDispatcherHostTester
public URLRequest::Interceptor,
public base::RefCountedThreadSafe<ResourceDispatcherHostTester> {
public:
- explicit ResourceDispatcherHostTester(MessageLoop* io_loop)
- : Receiver(ChildProcessInfo::RENDER_PROCESS, -1),
- host_(io_loop),
- ui_loop_(MessageLoop::current()),
- io_loop_(io_loop) {
+ explicit ResourceDispatcherHostTester()
+ : Receiver(ChildProcessInfo::RENDER_PROCESS, -1) {
URLRequest::RegisterRequestInterceptor(this);
}
virtual ~ResourceDispatcherHostTester() {
@@ -77,17 +74,20 @@ class ResourceDispatcherHostTester
}
void MakeTestRequest(int request_id, const GURL& url) {
- io_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &ResourceDispatcherHostTester::MakeTestRequestOnIOThread,
- request_id, url));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ this, &ResourceDispatcherHostTester::MakeTestRequestOnIOThread,
+ request_id, url));
MessageLoop::current()->Run(); // wait for Quit from IO thread
}
void WaitForScan(MockUserScriptMaster* master) {
master->TestStartScan();
MessageLoop::current()->RunAllPending(); // run the scan
- io_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &ResourceDispatcherHostTester::RunPending));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(this, &ResourceDispatcherHostTester::RunPending));
MessageLoop::current()->Run(); // wait for Quit from IO thread
}
@@ -149,7 +149,8 @@ class ResourceDispatcherHostTester
MessageLoop::current()->SetNestableTasksAllowed(false);
// return control to UI thread.
- ui_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask());
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE, new MessageLoop::QuitTask());
}
void MakeTestRequestOnIOThread(int request_id, const GURL& url) {
@@ -172,8 +173,6 @@ class ResourceDispatcherHostTester
}
ResourceDispatcherHost host_;
- MessageLoop* ui_loop_;
- MessageLoop* io_loop_;
// Note: these variables are accessed on both threads, but since we only
// one thread executes at a time, they are safe.
@@ -195,8 +194,7 @@ class UserScriptListenerTest : public testing::Test {
FilePath install_dir = profile_.GetPath()
.AppendASCII(ExtensionsService::kInstallDirectoryName);
- resource_tester_ =
- new ResourceDispatcherHostTester(io_thread_->message_loop());
+ resource_tester_ = new ResourceDispatcherHostTester();
master_ = new MockUserScriptMaster(install_dir);
diff --git a/chrome/browser/privacy_blacklist/blacklist_observer.cc b/chrome/browser/privacy_blacklist/blacklist_observer.cc
index 46d117cc..b62d0c8 100644
--- a/chrome/browser/privacy_blacklist/blacklist_observer.cc
+++ b/chrome/browser/privacy_blacklist/blacklist_observer.cc
@@ -8,6 +8,7 @@
#include "app/resource_bundle.h"
#include "base/string16.h"
#include "chrome/browser/blocked_popup_container.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/privacy_blacklist/blacklist.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
@@ -63,11 +64,9 @@ void BlacklistObserver::ContentBlocked(const URLRequest* request) {
const ResourceDispatcherHostRequestInfo* info =
ResourceDispatcherHost::InfoForRequest(request);
const GURL& gurl = request->url();
- BlockedContentNotice* task = new BlockedContentNotice(gurl, match, info);
- // Notify the UI that something non-visual has been blocked. We can
- // safely cast the delegate to the ResourceDispatherHost because it
- // is the only place where Blacklist::Match data is added to requests.
- static_cast<ResourceDispatcherHost*>(request->delegate())->
- ui_loop()->PostTask(FROM_HERE, task);
+ // Notify the UI that something non-visual has been blocked.
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ new BlockedContentNotice(gurl, match, info));
}
diff --git a/chrome/browser/renderer_host/cross_site_resource_handler.cc b/chrome/browser/renderer_host/cross_site_resource_handler.cc
index 8bc6517..158a4f3 100644
--- a/chrome/browser/renderer_host/cross_site_resource_handler.cc
+++ b/chrome/browser/renderer_host/cross_site_resource_handler.cc
@@ -7,7 +7,7 @@
#include "chrome/browser/renderer_host/cross_site_resource_handler.h"
#include "base/logging.h"
-#include "base/message_loop.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/render_view_host_delegate.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h"
@@ -161,10 +161,10 @@ bool CrossSiteResourceHandler::OnResponseCompleted(
// Here the request was canceled, which happens when selecting "take me
// back" from an interstitial. Nothing to do but cancel the pending
// render view host.
- CancelPendingRenderViewTask* task =
- new CancelPendingRenderViewTask(render_process_host_id_,
- render_view_id_);
- rdh_->ui_loop()->PostTask(FROM_HERE, task);
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ new CancelPendingRenderViewTask(
+ render_process_host_id_, render_view_id_));
return next_handler_->OnResponseCompleted(request_id, status,
security_info);
} else {
@@ -266,9 +266,8 @@ void CrossSiteResourceHandler::StartCrossSiteTransition(
// Tell the tab responsible for this request that a cross-site response is
// starting, so that it can tell its old renderer to run its onunload
// handler now. We will wait to hear the corresponding ClosePage_ACK.
- CrossSiteNotifyTask* task =
- new CrossSiteNotifyTask(render_process_host_id_,
- render_view_id_,
- request_id);
- rdh_->ui_loop()->PostTask(FROM_HERE, task);
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ new CrossSiteNotifyTask(
+ render_process_host_id_, render_view_id_, request_id));
}
diff --git a/chrome/browser/renderer_host/database_dispatcher_host.cc b/chrome/browser/renderer_host/database_dispatcher_host.cc
index f4c7e3b..c13f8c7 100644
--- a/chrome/browser/renderer_host/database_dispatcher_host.cc
+++ b/chrome/browser/renderer_host/database_dispatcher_host.cc
@@ -14,8 +14,7 @@
#include "third_party/sqlite/preprocessed/sqlite3.h"
#endif
-#include "base/thread.h"
-#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/renderer_host/resource_message_filter.h"
#include "chrome/common/render_messages.h"
#include "webkit/database/vfs_backend.h"
@@ -61,8 +60,7 @@ static void SendMessage(ResourceMessageFilter* sender,
// Opens the given database file, then schedules
// a task on the IO thread's message loop to send an IPC back to
// corresponding renderer process with the file handle.
-static void DatabaseOpenFile(MessageLoop* io_thread_message_loop,
- const OpenFileParams& params,
+static void DatabaseOpenFile(const OpenFileParams& params,
int32 message_id,
ResourceMessageFilter* sender) {
base::PlatformFile target_handle = base::kInvalidPlatformFileValue;
@@ -77,7 +75,8 @@ static void DatabaseOpenFile(MessageLoop* io_thread_message_loop,
response_params.file_handle = base::FileDescriptor(target_handle, true);
response_params.dir_handle = base::FileDescriptor(target_dir_handle, true);
#endif
- io_thread_message_loop->PostTask(FROM_HERE,
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
NewRunnableFunction(SendMessage, sender,
new ViewMsg_DatabaseOpenFileResponse(message_id, response_params)));
}
@@ -86,15 +85,15 @@ static void DatabaseOpenFile(MessageLoop* io_thread_message_loop,
// Deletes the given database file, then schedules
// a task on the IO thread's message loop to send an IPC back to
// corresponding renderer process with the error code.
-static void DatabaseDeleteFile(MessageLoop* io_thread_message_loop,
- const DeleteFileParams& params,
+static void DatabaseDeleteFile(const DeleteFileParams& params,
int32 message_id,
int reschedule_count,
ResourceMessageFilter* sender) {
// Return an error if the file could not be deleted
// after kNumDeleteRetries times.
if (!reschedule_count) {
- io_thread_message_loop->PostTask(FROM_HERE,
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
NewRunnableFunction(SendMessage, sender,
new ViewMsg_DatabaseDeleteFileResponse(message_id,
SQLITE_IOERR_DELETE)));
@@ -106,13 +105,14 @@ static void DatabaseDeleteFile(MessageLoop* io_thread_message_loop,
if (error_code == SQLITE_IOERR_DELETE) {
// If the file could not be deleted, try again.
MessageLoop::current()->PostDelayedTask(FROM_HERE,
- NewRunnableFunction(DatabaseDeleteFile, io_thread_message_loop,
- params, message_id, reschedule_count - 1, sender),
+ NewRunnableFunction(DatabaseDeleteFile, params, message_id,
+ reschedule_count - 1, sender),
kDelayDeleteRetryMs);
return;
}
- io_thread_message_loop->PostTask(FROM_HERE,
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
NewRunnableFunction(SendMessage, sender,
new ViewMsg_DatabaseDeleteFileResponse(message_id, error_code)));
}
@@ -121,12 +121,12 @@ static void DatabaseDeleteFile(MessageLoop* io_thread_message_loop,
// Gets the attributes of the given database file, then schedules
// a task on the IO thread's message loop to send an IPC back to
// corresponding renderer process.
-static void DatabaseGetFileAttributes(MessageLoop* io_thread_message_loop,
- const FilePath& file_name,
+static void DatabaseGetFileAttributes(const FilePath& file_name,
int32 message_id,
ResourceMessageFilter* sender) {
uint32 attributes = VfsBackend::GetFileAttributes(file_name);
- io_thread_message_loop->PostTask(FROM_HERE,
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
NewRunnableFunction(SendMessage, sender,
new ViewMsg_DatabaseGetFileAttributesResponse(
message_id, attributes)));
@@ -136,12 +136,12 @@ static void DatabaseGetFileAttributes(MessageLoop* io_thread_message_loop,
// Gets the size of the given file, then schedules a task
// on the IO thread's message loop to send an IPC back to
// the corresponding renderer process.
-static void DatabaseGetFileSize(MessageLoop* io_thread_message_loop,
- const FilePath& file_name,
+static void DatabaseGetFileSize(const FilePath& file_name,
int32 message_id,
ResourceMessageFilter* sender) {
int64 size = VfsBackend::GetFileSize(file_name);
- io_thread_message_loop->PostTask(FROM_HERE,
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
NewRunnableFunction(SendMessage, sender,
new ViewMsg_DatabaseGetFileSizeResponse(message_id, size)));
}
@@ -152,28 +152,11 @@ DatabaseDispatcherHost::DatabaseDispatcherHost(
const FilePath& profile_path,
ResourceMessageFilter* resource_message_filter)
: profile_path_(profile_path),
- resource_message_filter_(resource_message_filter),
- file_thread_message_loop_(
- g_browser_process->file_thread()->message_loop()) {
-}
-
-
-bool DatabaseDispatcherHost::IsDBMessage(const IPC::Message& message) {
- switch (message.type()) {
- case ViewHostMsg_DatabaseOpenFile::ID:
- case ViewHostMsg_DatabaseDeleteFile::ID:
- case ViewHostMsg_DatabaseGetFileAttributes::ID:
- case ViewHostMsg_DatabaseGetFileSize::ID:
- return true;
- default:
- return false;
- }
+ resource_message_filter_(resource_message_filter) {
}
bool DatabaseDispatcherHost::OnMessageReceived(
const IPC::Message& message, bool* message_was_ok) {
- if (!IsDBMessage(message))
- return false;
*message_was_ok = true;
bool handled = true;
@@ -230,9 +213,10 @@ void DatabaseDispatcherHost::OnDatabaseOpenFile(const FilePath& file_name,
params.desired_flags = desired_flags;
params.handle = resource_message_filter_->handle();
resource_message_filter_->AddRef();
- file_thread_message_loop_->PostTask(FROM_HERE,
- NewRunnableFunction(DatabaseOpenFile, MessageLoop::current(),
- params, message_id, resource_message_filter_));
+ ChromeThread::PostTask(
+ ChromeThread::FILE, FROM_HERE,
+ NewRunnableFunction(
+ DatabaseOpenFile, params, message_id, resource_message_filter_));
}
void DatabaseDispatcherHost::OnDatabaseDeleteFile(
@@ -249,10 +233,11 @@ void DatabaseDispatcherHost::OnDatabaseDeleteFile(
params.file_name = db_file_name;
params.sync_dir = sync_dir;
resource_message_filter_->AddRef();
- file_thread_message_loop_->PostTask(FROM_HERE,
- NewRunnableFunction(DatabaseDeleteFile, MessageLoop::current(),
- params, message_id, kNumDeleteRetries,
- resource_message_filter_));
+ ChromeThread::PostTask(
+ ChromeThread::FILE, FROM_HERE,
+ NewRunnableFunction(
+ DatabaseDeleteFile, params, message_id, kNumDeleteRetries,
+ resource_message_filter_));
}
void DatabaseDispatcherHost::OnDatabaseGetFileAttributes(
@@ -265,9 +250,11 @@ void DatabaseDispatcherHost::OnDatabaseGetFileAttributes(
}
resource_message_filter_->AddRef();
- file_thread_message_loop_->PostTask(FROM_HERE,
- NewRunnableFunction(DatabaseGetFileAttributes, MessageLoop::current(),
- db_file_name, message_id, resource_message_filter_));
+ ChromeThread::PostTask(
+ ChromeThread::FILE, FROM_HERE,
+ NewRunnableFunction(
+ DatabaseGetFileAttributes, db_file_name, message_id,
+ resource_message_filter_));
}
void DatabaseDispatcherHost::OnDatabaseGetFileSize(
@@ -280,7 +267,9 @@ void DatabaseDispatcherHost::OnDatabaseGetFileSize(
}
resource_message_filter_->AddRef();
- file_thread_message_loop_->PostTask(FROM_HERE,
- NewRunnableFunction(DatabaseGetFileSize, MessageLoop::current(),
- db_file_name, message_id, resource_message_filter_));
+ ChromeThread::PostTask(
+ ChromeThread::FILE, FROM_HERE,
+ NewRunnableFunction(
+ DatabaseGetFileSize, db_file_name, message_id,
+ resource_message_filter_));
}
diff --git a/chrome/browser/renderer_host/database_dispatcher_host.h b/chrome/browser/renderer_host/database_dispatcher_host.h
index 1b59f08..fd403d2 100644
--- a/chrome/browser/renderer_host/database_dispatcher_host.h
+++ b/chrome/browser/renderer_host/database_dispatcher_host.h
@@ -7,7 +7,6 @@
#include "base/file_path.h"
-class MessageLoop;
class ResourceMessageFilter;
namespace IPC {
@@ -23,6 +22,8 @@ class DatabaseDispatcherHost {
// Returns true iff the message is HTML5 DB related and was processed.
bool OnMessageReceived(const IPC::Message& message, bool* message_was_ok);
+ private:
+ // Message handlers.
// Processes the request to return a handle to the given DB file.
void OnDatabaseOpenFile(const FilePath& file_name,
int desired_flags,
@@ -41,10 +42,6 @@ class DatabaseDispatcherHost {
void OnDatabaseGetFileSize(const FilePath& file_name,
int32 message_id);
- private:
- // Determines if the message is HTML5 DB related.
- bool IsDBMessage(const IPC::Message& message);
-
// Returns the directory where all DB files are stored.
FilePath GetDBDir();
@@ -54,11 +51,10 @@ class DatabaseDispatcherHost {
// The user data directory.
FilePath profile_path_;
- // The ResourceMessageFilter instance of this renderer process.
+ // The ResourceMessageFilter instance of this renderer process. Can't keep
+ // a refptr or else we'll get into a cycle. It's always ok to use this in
+ // the IO thread since if the RMF goes away, this object is deleted.
ResourceMessageFilter* resource_message_filter_;
-
- // The message loop of the file thread.
- MessageLoop* file_thread_message_loop_;
};
#endif // CHROME_BROWSER_RENDERER_HOST_DATABASE_DISPATCHER_HOST_H_
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc
index 13ca1721..8f51253 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host.cc
+++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc
@@ -250,12 +250,10 @@ void PopulateResourceResponse(URLRequest* request,
} // namespace
-ResourceDispatcherHost::ResourceDispatcherHost(MessageLoop* io_loop)
- : ui_loop_(MessageLoop::current()),
- io_loop_(io_loop),
- ALLOW_THIS_IN_INITIALIZER_LIST(
+ResourceDispatcherHost::ResourceDispatcherHost()
+ : ALLOW_THIS_IN_INITIALIZER_LIST(
download_file_manager_(new DownloadFileManager(this))),
- download_request_manager_(new DownloadRequestManager(io_loop, ui_loop_)),
+ download_request_manager_(new DownloadRequestManager()),
ALLOW_THIS_IN_INITIALIZER_LIST(
save_file_manager_(new SaveFileManager(this))),
ALLOW_THIS_IN_INITIALIZER_LIST(user_script_listener_(
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.h b/chrome/browser/renderer_host/resource_dispatcher_host.h
index 147a7f9..c354b0a 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host.h
+++ b/chrome/browser/renderer_host/resource_dispatcher_host.h
@@ -31,7 +31,6 @@ class CrossSiteResourceHandler;
class DownloadFileManager;
class DownloadRequestManager;
class LoginHandler;
-class MessageLoop;
class PluginService;
class ResourceDispatcherHostRequestInfo;
class ResourceHandler;
@@ -105,8 +104,7 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
}
};
- // TODO(jam): take the parameter out once 25354 is done.
- explicit ResourceDispatcherHost(MessageLoop* io_loop);
+ ResourceDispatcherHost();
~ResourceDispatcherHost();
void Initialize();
@@ -193,8 +191,6 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
return webkit_thread_.get();
}
- MessageLoop* ui_loop() const { return ui_loop_; }
-
// Called when the onunload handler for a cross-site request has finished.
void OnClosePageACK(const ViewMsg_ClosePage_Params& params);
@@ -411,13 +407,6 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
PendingRequestList pending_requests_;
- // We cache the UI message loop so we can create new UI-related objects on it.
- MessageLoop* ui_loop_;
-
- // We cache the IO loop to ensure that GetURLRequest is only called from the
- // IO thread.
- MessageLoop* io_loop_;
-
// A timer that periodically calls UpdateLoadStates while pending_requests_
// is not empty.
base::RepeatingTimer<ResourceDispatcherHost> update_load_states_timer_;
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc b/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc
index 0b704b9..bbf97c3 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc
+++ b/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc
@@ -147,7 +147,6 @@ class ResourceDispatcherHostTest : public testing::Test,
ResourceDispatcherHostTest()
: Receiver(ChildProcessInfo::RENDER_PROCESS, -1),
io_thread_(ChromeThread::IO, &message_loop_),
- host_(NULL),
old_factory_(NULL) {
set_handle(base::GetCurrentProcessHandle());
}
diff --git a/chrome/browser/renderer_host/safe_browsing_resource_handler.cc b/chrome/browser/renderer_host/safe_browsing_resource_handler.cc
index 63cd46d..e33e796 100644
--- a/chrome/browser/renderer_host/safe_browsing_resource_handler.cc
+++ b/chrome/browser/renderer_host/safe_browsing_resource_handler.cc
@@ -185,8 +185,8 @@ void SafeBrowsingResourceHandler::OnUrlCheckResult(
} else {
displaying_blocking_page_ = true;
safe_browsing_->DisplayBlockingPage(
- url, resource_type_, result, this, rdh_->ui_loop(),
- render_process_host_id_, render_view_id_);
+ url, resource_type_, result, this, render_process_host_id_,
+ render_view_id_);
}
}
diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc
index 2dddb60..768f325 100644
--- a/chrome/browser/safe_browsing/safe_browsing_service.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_service.cc
@@ -210,7 +210,6 @@ void SafeBrowsingService::DisplayBlockingPage(const GURL& url,
ResourceType::Type resource_type,
UrlCheckResult result,
Client* client,
- MessageLoop* ui_loop,
int render_process_host_id,
int render_view_id) {
// Check if the user has already ignored our warning for this render_view
@@ -238,9 +237,10 @@ void SafeBrowsingService::DisplayBlockingPage(const GURL& url,
resource.render_view_id = render_view_id;
// The blocking page must be created from the UI thread.
- ui_loop->PostTask(FROM_HERE, NewRunnableMethod(this,
- &SafeBrowsingService::DoDisplayBlockingPage,
- resource));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(
+ this, &SafeBrowsingService::DoDisplayBlockingPage, resource));
}
// Invoked on the UI thread.
diff --git a/chrome/browser/safe_browsing/safe_browsing_service.h b/chrome/browser/safe_browsing/safe_browsing_service.h
index d5cca6b..cc42d84 100644
--- a/chrome/browser/safe_browsing/safe_browsing_service.h
+++ b/chrome/browser/safe_browsing/safe_browsing_service.h
@@ -101,7 +101,6 @@ class SafeBrowsingService
ResourceType::Type resource_type,
UrlCheckResult result,
Client* client,
- MessageLoop* ui_loop,
int render_process_host_id,
int render_view_id);
diff --git a/chrome/browser/utility_process_host_unittest.cc b/chrome/browser/utility_process_host_unittest.cc
index 9647ca5..3be0480 100644
--- a/chrome/browser/utility_process_host_unittest.cc
+++ b/chrome/browser/utility_process_host_unittest.cc
@@ -22,11 +22,14 @@ namespace {
class UtilityProcessHostTest : public testing::Test {
public:
- UtilityProcessHostTest() : io_thread_(ChromeThread::IO, &message_loop_) {
+ UtilityProcessHostTest()
+ : ui_thread_(ChromeThread::UI, &message_loop_),
+ io_thread_(ChromeThread::IO, &message_loop_) {
}
protected:
MessageLoopForIO message_loop_;
+ ChromeThread ui_thread_;
ChromeThread io_thread_;
};
@@ -139,7 +142,7 @@ TEST_F(UtilityProcessHostTest, ExtensionUnpacker) {
scoped_refptr<TestUtilityProcessHostClient> client(
new TestUtilityProcessHostClient());
- ResourceDispatcherHost rdh(NULL);
+ ResourceDispatcherHost rdh;
TestUtilityProcessHost* process_host =
new TestUtilityProcessHost(client.get(), &rdh);
// process_host will delete itself when it's done.
diff --git a/chrome/common/child_process_host.cc b/chrome/common/child_process_host.cc
index e3077a39..69655b4 100644
--- a/chrome/common/child_process_host.cc
+++ b/chrome/common/child_process_host.cc
@@ -8,7 +8,6 @@
#include "base/compiler_specific.h"
#include "base/file_path.h"
#include "base/logging.h"
-#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/process_util.h"
#include "base/singleton.h"
@@ -152,8 +151,8 @@ bool ChildProcessHost::Send(IPC::Message* msg) {
}
void ChildProcessHost::Notify(NotificationType type) {
- resource_dispatcher_host_->ui_loop()->PostTask(
- FROM_HERE, new ChildNotificationTask(type, this));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE, new ChildNotificationTask(type, this));
}
void ChildProcessHost::OnChildDied() {
@@ -249,9 +248,7 @@ ChildProcessHost::Iterator::Iterator()
ChildProcessHost::Iterator::Iterator(ProcessType type)
: all_(false), type_(type) {
- // IO loop can be NULL in unit tests.
- DCHECK(!MessageLoop::current() ||
- ChromeThread::CurrentlyOn(ChromeThread::IO)) <<
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)) <<
"ChildProcessInfo::Iterator must be used on the IO thread.";
iterator_ = Singleton<ChildProcessList>::get()->begin();
if (!Done() && (*iterator_)->type() != type_)