| 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_IO_DATA_H_ | 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ |
| 6 #define CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ | 6 #define CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> |
| 9 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/debug/stack_trace.h" |
| 10 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 11 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/synchronization/lock.h" |
| 13 #include "chrome/browser/net/chrome_url_request_context.h" | 16 #include "chrome/browser/net/chrome_url_request_context.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "content/browser/resource_context.h" |
| 15 #include "net/base/cookie_monster.h" | 19 #include "net/base/cookie_monster.h" |
| 16 | 20 |
| 17 class CommandLine; | 21 class CommandLine; |
| 18 class ChromeAppCacheService; | 22 class ChromeAppCacheService; |
| 19 class ChromeBlobStorageContext; | 23 class ChromeBlobStorageContext; |
| 20 class ChromeURLRequestContext; | |
| 21 class ChromeURLRequestContextGetter; | |
| 22 class ExtensionInfoMap; | 24 class ExtensionInfoMap; |
| 23 namespace fileapi { | 25 namespace fileapi { |
| 24 class FileSystemContext; | 26 class FileSystemContext; |
| 25 } | 27 } // namespace fileapi |
| 26 class HostContentSettingsMap; | 28 class HostContentSettingsMap; |
| 27 class HostZoomMap; | 29 class HostZoomMap; |
| 28 class IOThread; | 30 class IOThread; |
| 29 namespace net { | 31 namespace net { |
| 30 class DnsCertProvenanceChecker; | 32 class DnsCertProvenanceChecker; |
| 31 class NetLog; | 33 class NetLog; |
| 32 class ProxyConfigService; | 34 class ProxyConfigService; |
| 33 class ProxyService; | 35 class ProxyService; |
| 34 class SSLConfigService; | 36 class SSLConfigService; |
| 35 class TransportSecurityState; | 37 class TransportSecurityState; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 59 public: | 61 public: |
| 60 // These should only be called at most once each. Ownership is reversed when | 62 // These should only be called at most once each. Ownership is reversed when |
| 61 // they get called, from ProfileIOData owning ChromeURLRequestContext to vice | 63 // they get called, from ProfileIOData owning ChromeURLRequestContext to vice |
| 62 // versa. | 64 // versa. |
| 63 scoped_refptr<ChromeURLRequestContext> GetMainRequestContext() const; | 65 scoped_refptr<ChromeURLRequestContext> GetMainRequestContext() const; |
| 64 scoped_refptr<ChromeURLRequestContext> GetMediaRequestContext() const; | 66 scoped_refptr<ChromeURLRequestContext> GetMediaRequestContext() const; |
| 65 scoped_refptr<ChromeURLRequestContext> GetExtensionsRequestContext() const; | 67 scoped_refptr<ChromeURLRequestContext> GetExtensionsRequestContext() const; |
| 66 scoped_refptr<ChromeURLRequestContext> GetIsolatedAppRequestContext( | 68 scoped_refptr<ChromeURLRequestContext> GetIsolatedAppRequestContext( |
| 67 scoped_refptr<ChromeURLRequestContext> main_context, | 69 scoped_refptr<ChromeURLRequestContext> main_context, |
| 68 const std::string& app_id) const; | 70 const std::string& app_id) const; |
| 71 const content::ResourceContext& GetResourceContext() const; |
| 69 | 72 |
| 70 protected: | 73 protected: |
| 71 friend class base::RefCountedThreadSafe<ProfileIOData>; | 74 friend class base::RefCountedThreadSafe<ProfileIOData>; |
| 72 | 75 |
| 73 class RequestContext : public ChromeURLRequestContext { | 76 class RequestContext : public ChromeURLRequestContext { |
| 74 public: | 77 public: |
| 75 RequestContext(); | 78 RequestContext(); |
| 76 ~RequestContext(); | 79 ~RequestContext(); |
| 77 | 80 |
| 78 // Setter is used to transfer ownership of the ProfileIOData to the context. | 81 // Setter is used to transfer ownership of the ProfileIOData to the context. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 // because on linux it relies on initializing things through gconf, | 115 // because on linux it relies on initializing things through gconf, |
| 113 // and needs to be on the main thread. | 116 // and needs to be on the main thread. |
| 114 scoped_ptr<net::ProxyConfigService> proxy_config_service; | 117 scoped_ptr<net::ProxyConfigService> proxy_config_service; |
| 115 // The profile this struct was populated from. | 118 // The profile this struct was populated from. |
| 116 ProfileId profile_id; | 119 ProfileId profile_id; |
| 117 }; | 120 }; |
| 118 | 121 |
| 119 explicit ProfileIOData(bool is_incognito); | 122 explicit ProfileIOData(bool is_incognito); |
| 120 virtual ~ProfileIOData(); | 123 virtual ~ProfileIOData(); |
| 121 | 124 |
| 122 // Static helper functions to assist in common operations executed by | 125 void InitializeProfileParams(Profile* profile); |
| 123 // subtypes. | 126 void ApplyProfileParamsToContext(ChromeURLRequestContext* context) const; |
| 124 | 127 |
| 125 static void InitializeProfileParams(Profile* profile, ProfileParams* params); | 128 private: |
| 126 static void ApplyProfileParamsToContext(const ProfileParams& profile_params, | 129 class ResourceContext : public content::ResourceContext { |
| 127 ChromeURLRequestContext* context); | 130 public: |
| 131 explicit ResourceContext(const ProfileIOData* io_data); |
| 132 virtual ~ResourceContext(); |
| 133 |
| 134 private: |
| 135 virtual void EnsureInitialized() const; |
| 136 |
| 137 const ProfileIOData* const io_data_; |
| 138 }; |
| 128 | 139 |
| 129 // Lazy initializes the ProfileIOData object the first time a request context | 140 // Lazy initializes the ProfileIOData object the first time a request context |
| 130 // is requested. The lazy logic is implemented here. The actual initialization | 141 // is requested. The lazy logic is implemented here. The actual initialization |
| 131 // is done in LazyInitializeInternal(), implemented by subtypes. Static helper | 142 // is done in LazyInitializeInternal(), implemented by subtypes. Static helper |
| 132 // functions have been provided to assist in common operations. | 143 // functions have been provided to assist in common operations. |
| 133 void LazyInitialize() const; | 144 void LazyInitialize() const; |
| 134 | 145 |
| 135 // -------------------------------------------- | 146 // -------------------------------------------- |
| 136 // Virtual interface for subtypes to implement: | 147 // Virtual interface for subtypes to implement: |
| 137 // -------------------------------------------- | 148 // -------------------------------------------- |
| 138 | 149 |
| 139 // Does the actual initialization of the ProfileIOData subtype. Subtypes | 150 // Does the actual initialization of the ProfileIOData subtype. Subtypes |
| 140 // should use the static helper functions above to implement this. | 151 // should use the static helper functions above to implement this. |
| 141 virtual void LazyInitializeInternal() const = 0; | 152 virtual void LazyInitializeInternal(ProfileParams* profile_params) const = 0; |
| 142 | 153 |
| 143 // Does an on-demand initialization of a RequestContext for the given | 154 // Does an on-demand initialization of a RequestContext for the given |
| 144 // isolated app. | 155 // isolated app. |
| 145 virtual scoped_refptr<RequestContext> InitializeAppRequestContext( | 156 virtual scoped_refptr<RequestContext> InitializeAppRequestContext( |
| 146 scoped_refptr<ChromeURLRequestContext> main_context, | 157 scoped_refptr<ChromeURLRequestContext> main_context, |
| 147 const std::string& app_id) const = 0; | 158 const std::string& app_id) const = 0; |
| 148 | 159 |
| 149 // These functions are used to transfer ownership of the lazily initialized | 160 // These functions are used to transfer ownership of the lazily initialized |
| 150 // context from ProfileIOData to the URLRequestContextGetter. | 161 // context from ProfileIOData to the URLRequestContextGetter. |
| 151 virtual scoped_refptr<ChromeURLRequestContext> | 162 virtual scoped_refptr<ChromeURLRequestContext> |
| 152 AcquireMainRequestContext() const = 0; | 163 AcquireMainRequestContext() const = 0; |
| 153 virtual scoped_refptr<ChromeURLRequestContext> | 164 virtual scoped_refptr<ChromeURLRequestContext> |
| 154 AcquireMediaRequestContext() const = 0; | 165 AcquireMediaRequestContext() const = 0; |
| 155 virtual scoped_refptr<ChromeURLRequestContext> | 166 virtual scoped_refptr<ChromeURLRequestContext> |
| 156 AcquireExtensionsRequestContext() const = 0; | 167 AcquireExtensionsRequestContext() const = 0; |
| 157 virtual scoped_refptr<ChromeURLRequestContext> | 168 virtual scoped_refptr<ChromeURLRequestContext> |
| 158 AcquireIsolatedAppRequestContext( | 169 AcquireIsolatedAppRequestContext( |
| 159 scoped_refptr<ChromeURLRequestContext> main_context, | 170 scoped_refptr<ChromeURLRequestContext> main_context, |
| 160 const std::string& app_id) const = 0; | 171 const std::string& app_id) const = 0; |
| 161 | 172 |
| 173 |
| 162 mutable bool initialized_; | 174 mutable bool initialized_; |
| 175 mutable scoped_ptr<ProfileParams> profile_params_; |
| 176 mutable ResourceContext resource_context_; |
| 163 | 177 |
| 164 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); | 178 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); |
| 165 }; | 179 }; |
| 166 | 180 |
| 167 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ | 181 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ |
| OLD | NEW |