Index: mojo/loader/loader.cc |
diff --git a/mojo/loader/loader.cc b/mojo/loader/loader.cc |
index 1ab1ebf66a964b38e2dc62cd51a775f1a449406c..c78c6d2beebe8954c45dd8bcd3bb99fbd97c755a 100644 |
--- a/mojo/loader/loader.cc |
+++ b/mojo/loader/loader.cc |
@@ -3,6 +3,7 @@ |
// found in the LICENSE file. |
#include "base/message_loop/message_loop.h" |
+#include "base/threading/thread.h" |
#include "mojo/loader/loader.h" |
#include "mojo/loader/url_request_context_getter.h" |
#include "net/url_request/url_fetcher.h" |
@@ -30,6 +31,14 @@ void FetchDelegate::OnURLFetchComplete(const net::URLFetcher* source) { |
delete this; |
} |
+scoped_ptr<base::Thread> CreateIOThread(const char* name) { |
+ scoped_ptr<base::Thread> thread(new base::Thread(name)); |
+ base::Thread::Options options; |
+ options.message_loop_type = base::MessageLoop::TYPE_IO; |
+ thread->StartWithOptions(options); |
+ return thread.Pass(); |
+} |
+ |
} |
class Loader::Data { |
@@ -37,11 +46,18 @@ public: |
Data(); |
~Data(); |
+ scoped_ptr<base::Thread> network_thread_; |
+ scoped_ptr<base::Thread> cache_thread_; |
scoped_refptr<URLRequestContextGetter> url_request_context_getter; |
}; |
-Loader::Data::Data() |
- : url_request_context_getter(new URLRequestContextGetter()) { |
+Loader::Data::Data() { |
+ network_thread_ = CreateIOThread("network_thread"); |
+ cache_thread_ = CreateIOThread("cache_thread"); |
+ |
+ url_request_context_getter = new URLRequestContextGetter( |
+ network_thread_->message_loop_proxy(), |
+ cache_thread_->message_loop_proxy()); |
} |
Loader::Data::~Data() { |