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 #ifndef CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_ | 5 #ifndef CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_ |
6 #define CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_ | 6 #define CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "content/public/browser/browser_context.h" | 12 #include "content/public/browser/browser_context.h" |
13 #include "content/public/browser/content_browser_client.h" | 13 #include "content/public/browser/content_browser_client.h" |
14 #include "content/public/browser/resource_context.h" | |
15 #include "content/shell/browser/shell_url_request_context_getter.h" | |
James Cook
2014/10/07 20:14:17
You should be able to forward declare ShellURLRequ
Xi Han
2014/10/07 21:10:18
It is needed here because the method void set_url
James Cook
2014/10/07 22:38:45
Huh? set_url_request_context_getter() just sets ge
Xi Han
2014/10/08 13:48:48
There are two set_url_request_context_getter() in
| |
14 #include "net/url_request/url_request_job_factory.h" | 16 #include "net/url_request/url_request_job_factory.h" |
15 | 17 |
16 namespace net { | 18 namespace net { |
17 class NetLog; | 19 class NetLog; |
18 } | 20 } |
19 | 21 |
20 namespace content { | 22 namespace content { |
21 | 23 |
22 class DownloadManagerDelegate; | 24 class DownloadManagerDelegate; |
23 class ResourceContext; | |
24 class ShellDownloadManagerDelegate; | 25 class ShellDownloadManagerDelegate; |
25 class ShellURLRequestContextGetter; | |
26 | 26 |
27 class ShellBrowserContext : public BrowserContext { | 27 class ShellBrowserContext : public BrowserContext { |
28 public: | 28 public: |
29 ShellBrowserContext(bool off_the_record, net::NetLog* net_log); | 29 ShellBrowserContext(bool off_the_record, net::NetLog* net_log); |
30 virtual ~ShellBrowserContext(); | 30 virtual ~ShellBrowserContext(); |
31 | 31 |
32 void set_guest_manager_for_testing( | 32 void set_guest_manager_for_testing( |
33 BrowserPluginGuestManager* guest_manager) { | 33 BrowserPluginGuestManager* guest_manager) { |
34 guest_manager_ = guest_manager; | 34 guest_manager_ = guest_manager; |
35 } | 35 } |
(...skipping 20 matching lines...) Expand all Loading... | |
56 | 56 |
57 net::URLRequestContextGetter* CreateRequestContext( | 57 net::URLRequestContextGetter* CreateRequestContext( |
58 ProtocolHandlerMap* protocol_handlers, | 58 ProtocolHandlerMap* protocol_handlers, |
59 URLRequestInterceptorScopedVector request_interceptors); | 59 URLRequestInterceptorScopedVector request_interceptors); |
60 net::URLRequestContextGetter* CreateRequestContextForStoragePartition( | 60 net::URLRequestContextGetter* CreateRequestContextForStoragePartition( |
61 const base::FilePath& partition_path, | 61 const base::FilePath& partition_path, |
62 bool in_memory, | 62 bool in_memory, |
63 ProtocolHandlerMap* protocol_handlers, | 63 ProtocolHandlerMap* protocol_handlers, |
64 URLRequestInterceptorScopedVector request_interceptors); | 64 URLRequestInterceptorScopedVector request_interceptors); |
65 | 65 |
66 protected: | |
67 // Contains URLRequestContextGetter required for resource loading. | |
68 class ShellResourceContext : public ResourceContext { | |
69 public: | |
70 ShellResourceContext() : getter_(NULL) {} | |
James Cook
2014/10/07 20:14:16
Implement these in the .cc file
Xi Han
2014/10/07 21:10:18
Done.
| |
71 virtual ~ShellResourceContext() {} | |
72 | |
73 // ResourceContext implementation: | |
74 virtual net::HostResolver* GetHostResolver() override; | |
75 virtual net::URLRequestContext* GetRequestContext() override; | |
76 | |
77 void set_url_request_context_getter(ShellURLRequestContextGetter* getter) { | |
78 getter_ = getter; | |
79 } | |
80 | |
81 private: | |
82 ShellURLRequestContextGetter* getter_; | |
83 | |
84 DISALLOW_COPY_AND_ASSIGN(ShellResourceContext); | |
85 }; | |
86 | |
87 // Used by ShellBrowserContext to initiate and set different types of | |
88 // URLRequestContextGetter. | |
89 void set_url_request_context_getter(ShellURLRequestContextGetter* getter) { | |
90 url_request_getter_ = getter; | |
91 } | |
92 | |
93 ShellURLRequestContextGetter* get_url_request_context_getter() { | |
James Cook
2014/10/07 20:14:17
Just use url_request_context_getter(). And tradit
Xi Han
2014/10/07 21:10:18
Done.
| |
94 return url_request_getter_.get(); } | |
James Cook
2014/10/07 20:14:16
formatting
Xi Han
2014/10/07 21:10:18
Done.
| |
95 | |
96 scoped_ptr<ShellResourceContext> resource_context_; | |
97 | |
66 private: | 98 private: |
67 class ShellResourceContext; | |
68 | 99 |
69 // Performs initialization of the ShellBrowserContext while IO is still | 100 // Performs initialization of the ShellBrowserContext while IO is still |
70 // allowed on the current thread. | 101 // allowed on the current thread. |
71 void InitWhileIOAllowed(); | 102 void InitWhileIOAllowed(); |
72 | 103 |
73 bool off_the_record_; | 104 bool off_the_record_; |
74 net::NetLog* net_log_; | 105 net::NetLog* net_log_; |
75 bool ignore_certificate_errors_; | 106 bool ignore_certificate_errors_; |
76 base::FilePath path_; | 107 base::FilePath path_; |
77 BrowserPluginGuestManager* guest_manager_; | 108 BrowserPluginGuestManager* guest_manager_; |
78 scoped_ptr<ShellResourceContext> resource_context_; | |
79 scoped_ptr<ShellDownloadManagerDelegate> download_manager_delegate_; | 109 scoped_ptr<ShellDownloadManagerDelegate> download_manager_delegate_; |
80 scoped_refptr<ShellURLRequestContextGetter> url_request_getter_; | 110 scoped_refptr<ShellURLRequestContextGetter> url_request_getter_; |
81 | 111 |
82 DISALLOW_COPY_AND_ASSIGN(ShellBrowserContext); | 112 DISALLOW_COPY_AND_ASSIGN(ShellBrowserContext); |
83 }; | 113 }; |
84 | 114 |
85 } // namespace content | 115 } // namespace content |
86 | 116 |
87 #endif // CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_ | 117 #endif // CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_ |
OLD | NEW |