Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Unified Diff: chrome/browser/dom_ui/chrome_url_data_manager.cc

Issue 179069: Improve New Tab Page load performance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/dom_ui/chrome_url_data_manager.h ('k') | chrome/browser/dom_ui/dom_ui_theme_source.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/dom_ui/chrome_url_data_manager.cc
===================================================================
--- chrome/browser/dom_ui/chrome_url_data_manager.cc (revision 25173)
+++ chrome/browser/dom_ui/chrome_url_data_manager.cc (working copy)
@@ -12,6 +12,7 @@
#include "base/thread.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/ref_counted_util.h"
#include "chrome/common/url_constants.h"
@@ -225,9 +226,19 @@
job->SetMimeType(source->GetMimeType(path));
// Forward along the request to the data source.
- source->message_loop()->PostTask(FROM_HERE,
- NewRunnableMethod(source, &DataSource::StartDataRequest,
- path, request_id));
+ MessageLoop* target_message_loop = source->MessageLoopForRequestPath(path);
+ if (!target_message_loop) {
+ // The DataSource is agnostic to which thread StartDataRequest is called
+ // on for this path. Call directly into it from this thread, the IO
+ // thread.
+ source->StartDataRequest(path, request_id);
+ } else {
+ // The DataSource wants StartDataRequest to be called on a specific thread,
+ // usually the UI thread, for this path.
+ target_message_loop->PostTask(FROM_HERE,
+ NewRunnableMethod(source, &DataSource::StartDataRequest,
+ path, request_id));
+ }
return true;
}
@@ -261,12 +272,17 @@
void ChromeURLDataManager::DataSource::SendResponse(
RequestID request_id,
RefCountedBytes* bytes) {
- g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
+ ChromeThread::GetMessageLoop(ChromeThread::IO)->PostTask(FROM_HERE,
Mark Mentovai 2009/09/02 19:49:36 Here.
NewRunnableMethod(&chrome_url_data_manager,
&ChromeURLDataManager::DataAvailable,
request_id, scoped_refptr<RefCountedBytes>(bytes)));
}
+MessageLoop* ChromeURLDataManager::DataSource::MessageLoopForRequestPath(
+ const std::string& path) const {
+ return message_loop_;
+}
+
// static
void ChromeURLDataManager::DataSource::SetFontAndTextDirection(
DictionaryValue* localized_strings) {
« no previous file with comments | « chrome/browser/dom_ui/chrome_url_data_manager.h ('k') | chrome/browser/dom_ui/dom_ui_theme_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698