OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/shell/loader.h" | 5 #include "mojo/shell/loader.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "net/base/network_delegate.h" |
8 | 9 |
9 namespace mojo { | 10 namespace mojo { |
10 namespace shell { | 11 namespace shell { |
11 | 12 |
12 namespace { | 13 namespace { |
13 | 14 |
14 scoped_ptr<base::Thread> CreateIOThread(const char* name) { | 15 scoped_ptr<base::Thread> CreateIOThread(const char* name) { |
15 scoped_ptr<base::Thread> thread(new base::Thread(name)); | 16 scoped_ptr<base::Thread> thread(new base::Thread(name)); |
16 base::Thread::Options options; | 17 base::Thread::Options options; |
17 options.message_loop_type = base::MessageLoop::TYPE_IO; | 18 options.message_loop_type = base::MessageLoop::TYPE_IO; |
(...skipping 15 matching lines...) Expand all Loading... |
33 } | 34 } |
34 | 35 |
35 void Loader::Job::OnURLFetchComplete(const net::URLFetcher* source) { | 36 void Loader::Job::OnURLFetchComplete(const net::URLFetcher* source) { |
36 base::FilePath app_path; | 37 base::FilePath app_path; |
37 source->GetResponseAsFilePath(true, &app_path); | 38 source->GetResponseAsFilePath(true, &app_path); |
38 delegate_->DidCompleteLoad(source->GetURL(), app_path); | 39 delegate_->DidCompleteLoad(source->GetURL(), app_path); |
39 } | 40 } |
40 | 41 |
41 Loader::Loader(base::SingleThreadTaskRunner* network_runner, | 42 Loader::Loader(base::SingleThreadTaskRunner* network_runner, |
42 base::SingleThreadTaskRunner* file_runner, | 43 base::SingleThreadTaskRunner* file_runner, |
| 44 scoped_ptr<net::NetworkDelegate> network_delegate, |
43 base::FilePath base_path) | 45 base::FilePath base_path) |
44 : file_runner_(file_runner), | 46 : file_runner_(file_runner), |
45 cache_thread_(CreateIOThread("cache_thread")), | 47 cache_thread_(CreateIOThread("cache_thread")), |
46 url_request_context_getter_(new URLRequestContextGetter( | 48 url_request_context_getter_(new URLRequestContextGetter( |
47 base_path, network_runner, cache_thread_->message_loop_proxy())) { | 49 base_path, |
| 50 network_runner, |
| 51 file_runner, |
| 52 cache_thread_->message_loop_proxy(), |
| 53 network_delegate.Pass())) { |
48 } | 54 } |
49 | 55 |
50 Loader::~Loader() { | 56 Loader::~Loader() { |
51 } | 57 } |
52 | 58 |
53 scoped_ptr<Loader::Job> Loader::Load(const GURL& app_url, Delegate* delegate) { | 59 scoped_ptr<Loader::Job> Loader::Load(const GURL& app_url, Delegate* delegate) { |
54 scoped_ptr<Job> job(new Job(app_url, delegate)); | 60 scoped_ptr<Job> job(new Job(app_url, delegate)); |
55 job->fetcher_->SetRequestContext(url_request_context_getter_.get()); | 61 job->fetcher_->SetRequestContext(url_request_context_getter_.get()); |
56 job->fetcher_->SaveResponseToTemporaryFile(file_runner_.get()); | 62 job->fetcher_->SaveResponseToTemporaryFile(file_runner_.get()); |
57 job->fetcher_->Start(); | 63 job->fetcher_->Start(); |
58 return job.Pass(); | 64 return job.Pass(); |
59 } | 65 } |
60 | 66 |
61 } // namespace shell | 67 } // namespace shell |
62 } // namespace mojo | 68 } // namespace mojo |
OLD | NEW |