Chromium Code Reviews| 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_PROFILE_IMPL_IO_DATA_H_ | 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_IMPL_IO_DATA_H_ |
| 6 #define CHROME_BROWSER_PROFILES_PROFILE_IMPL_IO_DATA_H_ | 6 #define CHROME_BROWSER_PROFILES_PROFILE_IMPL_IO_DATA_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/hash_tables.h" | |
| 10 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
| 11 #include "chrome/browser/profiles/profile_io_data.h" | 12 #include "chrome/browser/profiles/profile_io_data.h" |
| 12 | 13 |
| 13 class ExtensionIOEventRouter; | 14 class ExtensionIOEventRouter; |
| 14 namespace net { | 15 namespace net { |
| 15 class NetworkDelegate; | 16 class NetworkDelegate; |
| 16 class DnsCertProvenanceChecker; | 17 class DnsCertProvenanceChecker; |
| 17 class HttpTransactionFactory; | 18 class HttpTransactionFactory; |
| 18 } // namespace net | 19 } // namespace net |
| 19 | 20 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 30 | 31 |
| 31 // Init() must be called before ~Handle(). It records all the necessary | 32 // Init() must be called before ~Handle(). It records all the necessary |
| 32 // parameters needed to construct a ChromeURLRequestContextGetter. | 33 // parameters needed to construct a ChromeURLRequestContextGetter. |
| 33 void Init(const FilePath& cookie_path, | 34 void Init(const FilePath& cookie_path, |
| 34 const FilePath& cache_path, | 35 const FilePath& cache_path, |
| 35 int cache_max_size, | 36 int cache_max_size, |
| 36 const FilePath& media_cache_path, | 37 const FilePath& media_cache_path, |
| 37 int media_cache_max_size, | 38 int media_cache_max_size, |
| 38 const FilePath& extensions_cookie_path); | 39 const FilePath& extensions_cookie_path); |
| 39 | 40 |
| 41 // Called on-demand for each isolated app. | |
| 42 void InitIsolatedApp(const Extension* app, | |
| 43 const FilePath& cookie_path, | |
| 44 const FilePath& cache_path, | |
| 45 int cache_max_size); | |
| 46 | |
| 40 scoped_refptr<ChromeURLRequestContextGetter> | 47 scoped_refptr<ChromeURLRequestContextGetter> |
| 41 GetMainRequestContextGetter() const; | 48 GetMainRequestContextGetter() const; |
| 42 scoped_refptr<ChromeURLRequestContextGetter> | 49 scoped_refptr<ChromeURLRequestContextGetter> |
| 43 GetMediaRequestContextGetter() const; | 50 GetMediaRequestContextGetter() const; |
| 44 scoped_refptr<ChromeURLRequestContextGetter> | 51 scoped_refptr<ChromeURLRequestContextGetter> |
| 45 GetExtensionsRequestContextGetter() const; | 52 GetExtensionsRequestContextGetter() const; |
| 53 scoped_refptr<ChromeURLRequestContextGetter> | |
|
willchan no longer on Chromium
2011/03/02 19:52:17
I think the key will be for you to create a subcla
Charlie Reis
2011/03/03 01:08:05
Thanks for the pointer. I think it's actually sim
| |
| 54 GetIsolatedAppRequestContextGetter(const Extension* app) const; | |
| 46 | 55 |
| 47 private: | 56 private: |
| 57 typedef base::hash_map<std::string, | |
| 58 scoped_refptr<ChromeURLRequestContextGetter> > | |
| 59 ChromeURLRequestContextGetterMap; | |
| 60 | |
| 48 // Lazily initialize ProfileParams. We do this on the calls to | 61 // Lazily initialize ProfileParams. We do this on the calls to |
| 49 // Get*RequestContextGetter(), so we only initialize ProfileParams right | 62 // Get*RequestContextGetter(), so we only initialize ProfileParams right |
| 50 // before posting a task to the IO thread to start using them. This prevents | 63 // before posting a task to the IO thread to start using them. This prevents |
| 51 // objects that are supposed to be deleted on the IO thread, but are created | 64 // objects that are supposed to be deleted on the IO thread, but are created |
| 52 // on the UI thread from being unnecessarily initialized. | 65 // on the UI thread from being unnecessarily initialized. |
| 53 void LazyInitialize() const; | 66 void LazyInitialize() const; |
| 54 | 67 |
| 55 // Ordering is important here. Do not reorder unless you know what you're | 68 // Ordering is important here. Do not reorder unless you know what you're |
| 56 // doing. We need to release |io_data_| *before* the getters, because we | 69 // doing. We need to release |io_data_| *before* the getters, because we |
| 57 // want to make sure that the last reference for |io_data_| is on the IO | 70 // want to make sure that the last reference for |io_data_| is on the IO |
| 58 // thread. The getters will be deleted on the IO thread, so they will | 71 // thread. The getters will be deleted on the IO thread, so they will |
| 59 // release their refs to their contexts, which will release the last refs to | 72 // release their refs to their contexts, which will release the last refs to |
| 60 // the ProfileIOData on the IO thread. | 73 // the ProfileIOData on the IO thread. |
| 61 mutable scoped_refptr<ChromeURLRequestContextGetter> | 74 mutable scoped_refptr<ChromeURLRequestContextGetter> |
| 62 main_request_context_getter_; | 75 main_request_context_getter_; |
| 63 mutable scoped_refptr<ChromeURLRequestContextGetter> | 76 mutable scoped_refptr<ChromeURLRequestContextGetter> |
| 64 media_request_context_getter_; | 77 media_request_context_getter_; |
| 65 mutable scoped_refptr<ChromeURLRequestContextGetter> | 78 mutable scoped_refptr<ChromeURLRequestContextGetter> |
| 66 extensions_request_context_getter_; | 79 extensions_request_context_getter_; |
| 80 mutable ChromeURLRequestContextGetterMap app_request_context_getter_map_; | |
| 67 const scoped_refptr<ProfileImplIOData> io_data_; | 81 const scoped_refptr<ProfileImplIOData> io_data_; |
| 68 | 82 |
| 69 Profile* const profile_; | 83 Profile* const profile_; |
| 70 | 84 |
| 71 mutable bool initialized_; | 85 mutable bool initialized_; |
| 72 | 86 |
| 73 DISALLOW_COPY_AND_ASSIGN(Handle); | 87 DISALLOW_COPY_AND_ASSIGN(Handle); |
| 74 }; | 88 }; |
| 75 | 89 |
| 76 private: | 90 private: |
| 77 friend class base::RefCountedThreadSafe<ProfileImplIOData>; | 91 friend class base::RefCountedThreadSafe<ProfileImplIOData>; |
| 78 | 92 |
| 79 struct LazyParams { | 93 struct LazyParams { |
| 80 LazyParams(); | 94 LazyParams(); |
| 81 ~LazyParams(); | 95 ~LazyParams(); |
| 82 | 96 |
| 83 // All of these parameters are intended to be read on the IO thread. | 97 // All of these parameters are intended to be read on the IO thread. |
| 84 FilePath cookie_path; | 98 FilePath cookie_path; |
| 85 FilePath cache_path; | 99 FilePath cache_path; |
| 86 int cache_max_size; | 100 int cache_max_size; |
| 87 FilePath media_cache_path; | 101 FilePath media_cache_path; |
| 88 int media_cache_max_size; | 102 int media_cache_max_size; |
| 89 FilePath extensions_cookie_path; | 103 FilePath extensions_cookie_path; |
| 90 IOThread* io_thread; | 104 IOThread* io_thread; |
| 91 | 105 |
| 92 ProfileParams profile_params; | 106 ProfileParams profile_params; |
| 93 }; | 107 }; |
| 94 | 108 |
| 109 typedef base::hash_map<std::string, LazyParams*> LazyParamsMap; | |
| 110 | |
| 95 ProfileImplIOData(); | 111 ProfileImplIOData(); |
| 96 virtual ~ProfileImplIOData(); | 112 virtual ~ProfileImplIOData(); |
| 97 | 113 |
| 98 // Lazily initializes ProfileImplIOData. | 114 // Lazily initializes ProfileImplIOData. |
| 99 virtual void LazyInitializeInternal() const; | 115 virtual void LazyInitializeInternal() const; |
| 116 virtual scoped_refptr<RequestContext> | |
| 117 InitializeAppRequestContext(const Extension *app) const; | |
| 100 virtual scoped_refptr<ChromeURLRequestContext> | 118 virtual scoped_refptr<ChromeURLRequestContext> |
| 101 AcquireMainRequestContext() const; | 119 AcquireMainRequestContext() const; |
| 102 virtual scoped_refptr<ChromeURLRequestContext> | 120 virtual scoped_refptr<ChromeURLRequestContext> |
| 103 AcquireMediaRequestContext() const; | 121 AcquireMediaRequestContext() const; |
| 104 virtual scoped_refptr<ChromeURLRequestContext> | 122 virtual scoped_refptr<ChromeURLRequestContext> |
| 105 AcquireExtensionsRequestContext() const; | 123 AcquireExtensionsRequestContext() const; |
| 124 virtual scoped_refptr<ChromeURLRequestContext> | |
| 125 AcquireIsolatedAppRequestContext( | |
| 126 const Extension* installed_app) const; | |
| 106 | 127 |
| 107 // Lazy initialization params. | 128 // Lazy initialization params. |
| 108 mutable scoped_ptr<LazyParams> lazy_params_; | 129 mutable scoped_ptr<LazyParams> lazy_params_; |
| 109 | 130 |
| 131 // One LazyParams per isolated app. | |
| 132 mutable LazyParamsMap lazy_params_map_; | |
| 133 | |
| 110 mutable scoped_refptr<RequestContext> main_request_context_; | 134 mutable scoped_refptr<RequestContext> main_request_context_; |
| 111 mutable scoped_refptr<RequestContext> media_request_context_; | 135 mutable scoped_refptr<RequestContext> media_request_context_; |
| 112 mutable scoped_refptr<RequestContext> extensions_request_context_; | 136 mutable scoped_refptr<RequestContext> extensions_request_context_; |
| 113 | 137 |
| 114 mutable scoped_refptr<ExtensionIOEventRouter> extension_io_event_router_; | 138 mutable scoped_refptr<ExtensionIOEventRouter> extension_io_event_router_; |
| 115 mutable scoped_ptr<net::NetworkDelegate> network_delegate_; | 139 mutable scoped_ptr<net::NetworkDelegate> network_delegate_; |
| 116 mutable scoped_ptr<net::DnsCertProvenanceChecker> dns_cert_checker_; | 140 mutable scoped_ptr<net::DnsCertProvenanceChecker> dns_cert_checker_; |
| 117 mutable scoped_ptr<net::HttpTransactionFactory> main_http_factory_; | 141 mutable scoped_ptr<net::HttpTransactionFactory> main_http_factory_; |
| 118 mutable scoped_ptr<net::HttpTransactionFactory> media_http_factory_; | 142 mutable scoped_ptr<net::HttpTransactionFactory> media_http_factory_; |
| 119 | 143 |
| 120 DISALLOW_COPY_AND_ASSIGN(ProfileImplIOData); | 144 DISALLOW_COPY_AND_ASSIGN(ProfileImplIOData); |
| 121 }; | 145 }; |
| 122 | 146 |
| 123 #endif // CHROME_BROWSER_PROFILES_PROFILE_IMPL_IO_DATA_H_ | 147 #endif // CHROME_BROWSER_PROFILES_PROFILE_IMPL_IO_DATA_H_ |
| OLD | NEW |