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 "content/shell/browser/shell_browser_context.h" | 5 #include "content/shell/browser/shell_browser_context.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/environment.h" | 9 #include "base/environment.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
22 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
23 #include "base/base_paths_win.h" | 23 #include "base/base_paths_win.h" |
24 #elif defined(OS_LINUX) | 24 #elif defined(OS_LINUX) |
25 #include "base/nix/xdg_util.h" | 25 #include "base/nix/xdg_util.h" |
26 #elif defined(OS_MACOSX) | 26 #elif defined(OS_MACOSX) |
27 #include "base/base_paths_mac.h" | 27 #include "base/base_paths_mac.h" |
28 #endif | 28 #endif |
29 | 29 |
30 namespace content { | 30 namespace content { |
31 | 31 |
32 class ShellBrowserContext::ShellResourceContext : public ResourceContext { | 32 class ShellBrowserContext::ShellResourceContext : public ResourceContext { |
James Cook
2014/10/07 16:24:54
Another way to solve this problem would be to move
Xi Han
2014/10/07 19:29:53
Done.
| |
33 public: | 33 public: |
34 ShellResourceContext() : getter_(NULL) {} | 34 ShellResourceContext() : getter_(NULL) {} |
35 virtual ~ShellResourceContext() {} | 35 virtual ~ShellResourceContext() {} |
36 | 36 |
37 // ResourceContext implementation: | 37 // ResourceContext implementation: |
38 virtual net::HostResolver* GetHostResolver() override { | 38 virtual net::HostResolver* GetHostResolver() override { |
39 CHECK(getter_); | 39 CHECK(getter_); |
40 return getter_->host_resolver(); | 40 return getter_->host_resolver(); |
41 } | 41 } |
42 virtual net::URLRequestContext* GetRequestContext() override { | 42 virtual net::URLRequestContext* GetRequestContext() override { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 122 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
123 if (cmd_line->HasSwitch(switches::kDumpRenderTree)) { | 123 if (cmd_line->HasSwitch(switches::kDumpRenderTree)) { |
124 download_manager_delegate_->SetDownloadBehaviorForTesting( | 124 download_manager_delegate_->SetDownloadBehaviorForTesting( |
125 path_.Append(FILE_PATH_LITERAL("downloads"))); | 125 path_.Append(FILE_PATH_LITERAL("downloads"))); |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 return download_manager_delegate_.get(); | 129 return download_manager_delegate_.get(); |
130 } | 130 } |
131 | 131 |
132 void ShellBrowserContext::set_url_request_context_getter( | |
Xi Han
2014/10/07 19:29:53
Change it to a regular inline setter function and
| |
133 ShellURLRequestContextGetter* getter) { | |
134 url_request_getter_ = getter; | |
135 resource_context_->set_url_request_context_getter(url_request_getter_.get()); | |
136 } | |
137 | |
138 ShellURLRequestContextGetter* | |
139 ShellBrowserContext::get_url_request_context_getter() { | |
Xi Han
2014/10/07 19:29:53
Change it to a regular inline getter function and
| |
140 return url_request_getter_.get(); | |
141 } | |
142 | |
132 net::URLRequestContextGetter* ShellBrowserContext::GetRequestContext() { | 143 net::URLRequestContextGetter* ShellBrowserContext::GetRequestContext() { |
133 return GetDefaultStoragePartition(this)->GetURLRequestContext(); | 144 return GetDefaultStoragePartition(this)->GetURLRequestContext(); |
134 } | 145 } |
135 | 146 |
136 net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext( | 147 net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext( |
137 ProtocolHandlerMap* protocol_handlers, | 148 ProtocolHandlerMap* protocol_handlers, |
138 URLRequestInterceptorScopedVector request_interceptors) { | 149 URLRequestInterceptorScopedVector request_interceptors) { |
139 DCHECK(!url_request_getter_.get()); | 150 DCHECK(!url_request_getter_.get()); |
140 url_request_getter_ = new ShellURLRequestContextGetter( | 151 url_request_getter_ = new ShellURLRequestContextGetter( |
James Cook
2014/10/07 16:24:54
It you decide to go the SetURLRequestContextGetter
Xi Han
2014/10/07 19:29:53
I adopt your suggestion to declare resource_contex
| |
141 ignore_certificate_errors_, | 152 ignore_certificate_errors_, |
142 GetPath(), | 153 GetPath(), |
143 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO), | 154 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO), |
144 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE), | 155 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE), |
145 protocol_handlers, | 156 protocol_handlers, |
146 request_interceptors.Pass(), | 157 request_interceptors.Pass(), |
147 net_log_); | 158 net_log_); |
148 resource_context_->set_url_request_context_getter(url_request_getter_.get()); | 159 resource_context_->set_url_request_context_getter(url_request_getter_.get()); |
149 return url_request_getter_.get(); | 160 return url_request_getter_.get(); |
150 } | 161 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 | 207 |
197 PushMessagingService* ShellBrowserContext::GetPushMessagingService() { | 208 PushMessagingService* ShellBrowserContext::GetPushMessagingService() { |
198 return NULL; | 209 return NULL; |
199 } | 210 } |
200 | 211 |
201 SSLHostStateDelegate* ShellBrowserContext::GetSSLHostStateDelegate() { | 212 SSLHostStateDelegate* ShellBrowserContext::GetSSLHostStateDelegate() { |
202 return NULL; | 213 return NULL; |
203 } | 214 } |
204 | 215 |
205 } // namespace content | 216 } // namespace content |
OLD | NEW |