| 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. |
| 79 void set_profile_io_data(const ProfileIOData* profile_io_data) { | 82 void set_profile_io_data(const ProfileIOData* profile_io_data) { |
| 80 profile_io_data_ = profile_io_data; | 83 profile_io_data_ = profile_io_data; |
| 81 } | 84 } |
| 82 | 85 |
| 83 private: | 86 private: |
| 84 scoped_refptr<const ProfileIOData> profile_io_data_; | 87 scoped_refptr<const ProfileIOData> profile_io_data_; |
| 85 }; | 88 }; |
| 86 | 89 |
| 90 class ProfileResourceContextGetter : public content::ResourceContextGetter { |
| 91 public: |
| 92 explicit ProfileResourceContextGetter(ProfileIOData* profile_io_data); |
| 93 virtual ~ProfileResourceContextGetter(); |
| 94 |
| 95 #ifndef NDEBUG |
| 96 void PrintStacktrace() const; |
| 97 #endif |
| 98 |
| 99 private: |
| 100 virtual const content::ResourceContext& GetImpl(); |
| 101 ProfileIOData* const profile_io_data_; |
| 102 |
| 103 #ifndef NDEBUG |
| 104 base::debug::StackTrace stacktrace_; |
| 105 #endif |
| 106 |
| 107 DISALLOW_COPY_AND_ASSIGN(ProfileResourceContextGetter); |
| 108 }; |
| 109 |
| 87 // Created on the UI thread, read on the IO thread during ProfileIOData lazy | 110 // Created on the UI thread, read on the IO thread during ProfileIOData lazy |
| 88 // initialization. | 111 // initialization. |
| 89 struct ProfileParams { | 112 struct ProfileParams { |
| 90 ProfileParams(); | 113 ProfileParams(); |
| 91 ~ProfileParams(); | 114 ~ProfileParams(); |
| 92 | 115 |
| 93 bool is_incognito; | 116 bool is_incognito; |
| 94 bool clear_local_state_on_exit; | 117 bool clear_local_state_on_exit; |
| 95 std::string accept_language; | 118 std::string accept_language; |
| 96 std::string accept_charset; | 119 std::string accept_charset; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 112 // because on linux it relies on initializing things through gconf, | 135 // because on linux it relies on initializing things through gconf, |
| 113 // and needs to be on the main thread. | 136 // and needs to be on the main thread. |
| 114 scoped_ptr<net::ProxyConfigService> proxy_config_service; | 137 scoped_ptr<net::ProxyConfigService> proxy_config_service; |
| 115 // The profile this struct was populated from. | 138 // The profile this struct was populated from. |
| 116 ProfileId profile_id; | 139 ProfileId profile_id; |
| 117 }; | 140 }; |
| 118 | 141 |
| 119 explicit ProfileIOData(bool is_incognito); | 142 explicit ProfileIOData(bool is_incognito); |
| 120 virtual ~ProfileIOData(); | 143 virtual ~ProfileIOData(); |
| 121 | 144 |
| 145 protected: |
| 146 void set_resource_context( |
| 147 const content::ResourceContext* resource_context) const; |
| 148 |
| 122 // Static helper functions to assist in common operations executed by | 149 // Static helper functions to assist in common operations executed by |
| 123 // subtypes. | 150 // subtypes. |
| 124 | 151 |
| 125 static void InitializeProfileParams(Profile* profile, ProfileParams* params); | 152 static void InitializeProfileParams(Profile* profile, ProfileParams* params); |
| 126 static void ApplyProfileParamsToContext(const ProfileParams& profile_params, | 153 static void ApplyProfileParamsToContext(const ProfileParams& profile_params, |
| 127 ChromeURLRequestContext* context); | 154 ChromeURLRequestContext* context); |
| 128 | 155 |
| 156 private: |
| 129 // Lazy initializes the ProfileIOData object the first time a request context | 157 // Lazy initializes the ProfileIOData object the first time a request context |
| 130 // is requested. The lazy logic is implemented here. The actual initialization | 158 // is requested. The lazy logic is implemented here. The actual initialization |
| 131 // is done in LazyInitializeInternal(), implemented by subtypes. Static helper | 159 // is done in LazyInitializeInternal(), implemented by subtypes. Static helper |
| 132 // functions have been provided to assist in common operations. | 160 // functions have been provided to assist in common operations. |
| 133 void LazyInitialize() const; | 161 void LazyInitialize() const; |
| 134 | 162 |
| 135 // -------------------------------------------- | 163 // -------------------------------------------- |
| 136 // Virtual interface for subtypes to implement: | 164 // Virtual interface for subtypes to implement: |
| 137 // -------------------------------------------- | 165 // -------------------------------------------- |
| 138 | 166 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 154 AcquireMediaRequestContext() const = 0; | 182 AcquireMediaRequestContext() const = 0; |
| 155 virtual scoped_refptr<ChromeURLRequestContext> | 183 virtual scoped_refptr<ChromeURLRequestContext> |
| 156 AcquireExtensionsRequestContext() const = 0; | 184 AcquireExtensionsRequestContext() const = 0; |
| 157 virtual scoped_refptr<ChromeURLRequestContext> | 185 virtual scoped_refptr<ChromeURLRequestContext> |
| 158 AcquireIsolatedAppRequestContext( | 186 AcquireIsolatedAppRequestContext( |
| 159 scoped_refptr<ChromeURLRequestContext> main_context, | 187 scoped_refptr<ChromeURLRequestContext> main_context, |
| 160 const std::string& app_id) const = 0; | 188 const std::string& app_id) const = 0; |
| 161 | 189 |
| 162 mutable bool initialized_; | 190 mutable bool initialized_; |
| 163 | 191 |
| 192 mutable scoped_ptr<const content::ResourceContext> resource_context_; |
| 193 |
| 194 // These members are used purely for debugging leaks. |
| 195 base::Lock lock_; |
| 196 std::set<const ProfileResourceContextGetter*> resource_context_getters_; |
| 197 |
| 164 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); | 198 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); |
| 165 }; | 199 }; |
| 166 | 200 |
| 167 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ | 201 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ |
| OLD | NEW |