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

Side by Side Diff: android_webview/browser/net/aw_url_request_context_getter.h

Issue 11308362: Add StoragePartition's ProtocolHandlers at URLRequestContext construction time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address awong's comments Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 ANDROID_WEBVIEW_BROWSER_NET_AW_URL_REQUEST_CONTEXT_GETTER_H_ 5 #ifndef ANDROID_WEBVIEW_BROWSER_NET_AW_URL_REQUEST_CONTEXT_GETTER_H_
6 #define ANDROID_WEBVIEW_BROWSER_NET_AW_URL_REQUEST_CONTEXT_GETTER_H_ 6 #define ANDROID_WEBVIEW_BROWSER_NET_AW_URL_REQUEST_CONTEXT_GETTER_H_
7 7
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
8 #include "content/public/browser/browser_thread_delegate.h" 11 #include "content/public/browser/browser_thread_delegate.h"
9
10 #include "base/memory/scoped_ptr.h"
11 #include "net/http/http_network_session.h" 12 #include "net/http/http_network_session.h"
12 #include "net/url_request/url_request_context_getter.h" 13 #include "net/url_request/url_request_context_getter.h"
13 14 #include "net/url_request/url_request_job_factory.h"
14 namespace content {
15 class ResourceContext;
16 }
17 15
18 namespace net { 16 namespace net {
19 class HttpTransactionFactory; 17 class HttpTransactionFactory;
20 class ProxyConfigService; 18 class ProxyConfigService;
21 class URLRequestContext; 19 class URLRequestContext;
22 class URLRequestJobFactory; 20 class URLRequestJobFactory;
23 } 21 }
24 22
25 namespace android_webview { 23 namespace android_webview {
26 24
27 class AwBrowserContext; 25 class AwBrowserContext;
28 class AwNetworkDelegate; 26 class AwNetworkDelegate;
29 27
30 class AwURLRequestContextGetter : public net::URLRequestContextGetter, 28 class AwURLRequestContextGetter : public net::URLRequestContextGetter,
31 public content::BrowserThreadDelegate { 29 public content::BrowserThreadDelegate {
32 public: 30 public:
33 AwURLRequestContextGetter(AwBrowserContext* browser_context); 31 explicit AwURLRequestContextGetter(AwBrowserContext* browser_context);
34 32
35 void InitializeOnNetworkThread(); 33 void InitializeOnNetworkThread();
36 34
37 content::ResourceContext* GetResourceContext();
38
39 // content::BrowserThreadDelegate implementation. 35 // content::BrowserThreadDelegate implementation.
40 virtual void Init() OVERRIDE; 36 virtual void Init() OVERRIDE;
41 virtual void CleanUp() OVERRIDE {} 37 virtual void CleanUp() OVERRIDE {}
42 38
43 // net::URLRequestContextGetter implementation. 39 // net::URLRequestContextGetter implementation.
44 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; 40 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE;
45 virtual scoped_refptr<base::SingleThreadTaskRunner> 41 virtual scoped_refptr<base::SingleThreadTaskRunner>
46 GetNetworkTaskRunner() const OVERRIDE; 42 GetNetworkTaskRunner() const OVERRIDE;
47 43
44 // Prior to GetURLRequestContext() being called, SetProtocolHandlers() is
45 // called to hand over the ProtocolHandlers that GetURLRequestContext() will
46 // later install into |job_factory_|. This ordering is enforced by having
47 // AwBrowserContext::CreateRequestContext() call SetProtocolHandlers().
48 // SetProtocolHandlers() is necessary because the ProtocolHandlers are created
49 // on the UI thread while |job_factory_| must be created on the IO thread.
50 void SetProtocolHandlers(
51 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
52 blob_protocol_handler,
53 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
54 file_system_protocol_handler,
55 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
56 developer_protocol_handler,
57 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
58 chrome_protocol_handler,
59 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
60 chrome_devtools_protocol_handler);
61
48 private: 62 private:
49 virtual ~AwURLRequestContextGetter(); 63 virtual ~AwURLRequestContextGetter();
50 64
51 void PopulateNetworkSessionParams(net::HttpNetworkSession::Params* params); 65 void PopulateNetworkSessionParams(net::HttpNetworkSession::Params* params);
52 66
53 AwBrowserContext* browser_context_; // weak 67 AwBrowserContext* browser_context_; // weak
54 scoped_ptr<net::URLRequestContext> url_request_context_; 68 scoped_ptr<net::URLRequestContext> url_request_context_;
55 scoped_ptr<net::ProxyConfigService> proxy_config_service_; 69 scoped_ptr<net::ProxyConfigService> proxy_config_service_;
56 scoped_ptr<content::ResourceContext> resource_context_;
57 scoped_ptr<net::URLRequestJobFactory> job_factory_; 70 scoped_ptr<net::URLRequestJobFactory> job_factory_;
58 scoped_ptr<net::HttpTransactionFactory> main_http_factory_; 71 scoped_ptr<net::HttpTransactionFactory> main_http_factory_;
59 72
73 // ProtocolHandlers are stored here between SetProtocolHandlers() and
74 // GetURLRequestContext() calls.
75 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> blob_protocol_handler_;
76 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
77 file_system_protocol_handler_;
78 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
79 developer_protocol_handler_;
80 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
81 chrome_protocol_handler_;
82 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
83 chrome_devtools_protocol_handler_;
84
60 DISALLOW_COPY_AND_ASSIGN(AwURLRequestContextGetter); 85 DISALLOW_COPY_AND_ASSIGN(AwURLRequestContextGetter);
61 }; 86 };
62 87
63 } // namespace android_webview 88 } // namespace android_webview
64 89
65 #endif // ANDROID_WEBVIEW_BROWSER_NET_AW_URL_REQUEST_CONTEXT_GETTER_H_ 90 #endif // ANDROID_WEBVIEW_BROWSER_NET_AW_URL_REQUEST_CONTEXT_GETTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698