OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_PROFILES_OFF_THE_RECORD_PROFILE_IO_DATA_H_ | 5 #ifndef CHROME_BROWSER_PROFILES_OFF_THE_RECORD_PROFILE_IO_DATA_H_ |
6 #define CHROME_BROWSER_PROFILES_OFF_THE_RECORD_PROFILE_IO_DATA_H_ | 6 #define CHROME_BROWSER_PROFILES_OFF_THE_RECORD_PROFILE_IO_DATA_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/hash_tables.h" |
11 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
12 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
13 #include "chrome/browser/profiles/profile_io_data.h" | 14 #include "chrome/browser/profiles/profile_io_data.h" |
14 | 15 |
15 class ChromeURLRequestContext; | 16 class ChromeURLRequestContext; |
16 class ChromeURLRequestContextGetter; | 17 class ChromeURLRequestContextGetter; |
17 class IOThread; | 18 class IOThread; |
18 class Profile; | 19 class Profile; |
19 | 20 |
20 // OffTheRecordProfile owns a OffTheRecordProfileIOData::Handle, which holds a | 21 // OffTheRecordProfile owns a OffTheRecordProfileIOData::Handle, which holds a |
(...skipping 12 matching lines...) Expand all Loading... |
33 public: | 34 public: |
34 class Handle { | 35 class Handle { |
35 public: | 36 public: |
36 explicit Handle(Profile* profile); | 37 explicit Handle(Profile* profile); |
37 ~Handle(); | 38 ~Handle(); |
38 | 39 |
39 scoped_refptr<ChromeURLRequestContextGetter> | 40 scoped_refptr<ChromeURLRequestContextGetter> |
40 GetMainRequestContextGetter() const; | 41 GetMainRequestContextGetter() const; |
41 scoped_refptr<ChromeURLRequestContextGetter> | 42 scoped_refptr<ChromeURLRequestContextGetter> |
42 GetExtensionsRequestContextGetter() const; | 43 GetExtensionsRequestContextGetter() const; |
| 44 scoped_refptr<ChromeURLRequestContextGetter> |
| 45 GetIsolatedAppRequestContextGetter( |
| 46 const std::string& app_id) const; |
43 | 47 |
44 private: | 48 private: |
| 49 typedef base::hash_map<std::string, |
| 50 scoped_refptr<ChromeURLRequestContextGetter> > |
| 51 ChromeURLRequestContextGetterMap; |
| 52 |
45 // Lazily initialize ProfileParams. We do this on the calls to | 53 // Lazily initialize ProfileParams. We do this on the calls to |
46 // Get*RequestContextGetter(), so we only initialize ProfileParams right | 54 // Get*RequestContextGetter(), so we only initialize ProfileParams right |
47 // before posting a task to the IO thread to start using them. This prevents | 55 // before posting a task to the IO thread to start using them. This prevents |
48 // objects that are supposed to be deleted on the IO thread, but are created | 56 // objects that are supposed to be deleted on the IO thread, but are created |
49 // on the UI thread from being unnecessarily initialized. | 57 // on the UI thread from being unnecessarily initialized. |
50 void LazyInitialize() const; | 58 void LazyInitialize() const; |
51 | 59 |
52 // Ordering is important here. Do not reorder unless you know what you're | 60 // Ordering is important here. Do not reorder unless you know what you're |
53 // doing. We need to release |io_data_| *before* the getters, because we | 61 // doing. We need to release |io_data_| *before* the getters, because we |
54 // want to make sure that the last reference for |io_data_| is on the IO | 62 // want to make sure that the last reference for |io_data_| is on the IO |
55 // thread. The getters will be deleted on the IO thread, so they will | 63 // thread. The getters will be deleted on the IO thread, so they will |
56 // release their refs to their contexts, which will release the last refs to | 64 // release their refs to their contexts, which will release the last refs to |
57 // the ProfileIOData on the IO thread. | 65 // the ProfileIOData on the IO thread. |
58 mutable scoped_refptr<ChromeURLRequestContextGetter> | 66 mutable scoped_refptr<ChromeURLRequestContextGetter> |
59 main_request_context_getter_; | 67 main_request_context_getter_; |
60 mutable scoped_refptr<ChromeURLRequestContextGetter> | 68 mutable scoped_refptr<ChromeURLRequestContextGetter> |
61 extensions_request_context_getter_; | 69 extensions_request_context_getter_; |
| 70 mutable ChromeURLRequestContextGetterMap |
| 71 app_request_context_getter_map_; |
62 const scoped_refptr<OffTheRecordProfileIOData> io_data_; | 72 const scoped_refptr<OffTheRecordProfileIOData> io_data_; |
63 | 73 |
64 Profile* const profile_; | 74 Profile* const profile_; |
65 | 75 |
66 mutable bool initialized_; | 76 mutable bool initialized_; |
67 | 77 |
68 DISALLOW_COPY_AND_ASSIGN(Handle); | 78 DISALLOW_COPY_AND_ASSIGN(Handle); |
69 }; | 79 }; |
70 | 80 |
71 private: | 81 private: |
72 friend class base::RefCountedThreadSafe<OffTheRecordProfileIOData>; | 82 friend class base::RefCountedThreadSafe<OffTheRecordProfileIOData>; |
73 | 83 |
74 struct LazyParams { | 84 struct LazyParams { |
75 LazyParams(); | 85 LazyParams(); |
76 ~LazyParams(); | 86 ~LazyParams(); |
77 | 87 |
78 IOThread* io_thread; | 88 IOThread* io_thread; |
79 ProfileParams profile_params; | 89 ProfileParams profile_params; |
80 }; | 90 }; |
81 | 91 |
| 92 typedef base::hash_map<std::string, net::HttpTransactionFactory* > |
| 93 HttpTransactionFactoryMap; |
| 94 |
82 OffTheRecordProfileIOData(); | 95 OffTheRecordProfileIOData(); |
83 ~OffTheRecordProfileIOData(); | 96 ~OffTheRecordProfileIOData(); |
84 | 97 |
85 // Lazily initializes ProfileIOData. | 98 // Lazily initializes ProfileIOData. |
86 virtual void LazyInitializeInternal() const; | 99 virtual void LazyInitializeInternal() const; |
| 100 virtual scoped_refptr<RequestContext> InitializeAppRequestContext( |
| 101 scoped_refptr<ChromeURLRequestContext> main_context, |
| 102 const std::string& app_id) const; |
87 virtual scoped_refptr<ChromeURLRequestContext> | 103 virtual scoped_refptr<ChromeURLRequestContext> |
88 AcquireMainRequestContext() const; | 104 AcquireMainRequestContext() const; |
89 virtual scoped_refptr<ChromeURLRequestContext> | 105 virtual scoped_refptr<ChromeURLRequestContext> |
90 AcquireMediaRequestContext() const; | 106 AcquireMediaRequestContext() const; |
91 virtual scoped_refptr<ChromeURLRequestContext> | 107 virtual scoped_refptr<ChromeURLRequestContext> |
92 AcquireExtensionsRequestContext() const; | 108 AcquireExtensionsRequestContext() const; |
| 109 virtual scoped_refptr<ChromeURLRequestContext> |
| 110 AcquireIsolatedAppRequestContext( |
| 111 scoped_refptr<ChromeURLRequestContext> main_context, |
| 112 const std::string& app_id) const; |
93 | 113 |
94 // Lazy initialization params. | 114 // Lazy initialization params. |
95 mutable scoped_ptr<LazyParams> lazy_params_; | 115 mutable scoped_ptr<LazyParams> lazy_params_; |
96 | 116 |
97 mutable bool initialized_; | 117 mutable bool initialized_; |
98 mutable scoped_refptr<RequestContext> main_request_context_; | 118 mutable scoped_refptr<RequestContext> main_request_context_; |
99 // NOTE: |media_request_context_| just points to the same context that | 119 // NOTE: |media_request_context_| just points to the same context that |
100 // |main_request_context_| points to. | 120 // |main_request_context_| points to. |
101 mutable scoped_refptr<RequestContext> media_request_context_; | 121 mutable scoped_refptr<RequestContext> media_request_context_; |
102 mutable scoped_refptr<RequestContext> extensions_request_context_; | 122 mutable scoped_refptr<RequestContext> extensions_request_context_; |
103 | 123 |
104 mutable scoped_ptr<net::NetworkDelegate> network_delegate_; | 124 mutable scoped_ptr<net::NetworkDelegate> network_delegate_; |
105 mutable scoped_ptr<net::DnsCertProvenanceChecker> dns_cert_checker_; | 125 mutable scoped_ptr<net::DnsCertProvenanceChecker> dns_cert_checker_; |
106 mutable scoped_ptr<net::HttpTransactionFactory> main_http_factory_; | 126 mutable scoped_ptr<net::HttpTransactionFactory> main_http_factory_; |
107 | 127 |
| 128 // One HttpTransactionFactory per isolated app. |
| 129 mutable HttpTransactionFactoryMap app_http_factory_map_; |
| 130 |
108 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileIOData); | 131 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileIOData); |
109 }; | 132 }; |
110 | 133 |
111 #endif // CHROME_BROWSER_PROFILES_OFF_THE_RECORD_PROFILE_IO_DATA_H_ | 134 #endif // CHROME_BROWSER_PROFILES_OFF_THE_RECORD_PROFILE_IO_DATA_H_ |
OLD | NEW |