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 <string> | 9 #include <string> |
10 | 10 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 // Conceptually speaking, the ProfileIOData represents data that lives on the IO | 66 // Conceptually speaking, the ProfileIOData represents data that lives on the IO |
67 // thread that is owned by a Profile, such as, but not limited to, network | 67 // thread that is owned by a Profile, such as, but not limited to, network |
68 // objects like CookieMonster, HttpTransactionFactory, etc. Profile owns | 68 // objects like CookieMonster, HttpTransactionFactory, etc. Profile owns |
69 // ProfileIOData, but will make sure to delete it on the IO thread (except | 69 // ProfileIOData, but will make sure to delete it on the IO thread (except |
70 // possibly in unit tests where there is no IO thread). | 70 // possibly in unit tests where there is no IO thread). |
71 class ProfileIOData { | 71 class ProfileIOData { |
72 public: | 72 public: |
73 virtual ~ProfileIOData(); | 73 virtual ~ProfileIOData(); |
74 | 74 |
| 75 static ProfileIOData* FromResourceContext(content::ResourceContext* rc); |
| 76 |
75 // Returns true if |scheme| is handled in Chrome, or by default handlers in | 77 // Returns true if |scheme| is handled in Chrome, or by default handlers in |
76 // net::URLRequest. | 78 // net::URLRequest. |
77 static bool IsHandledProtocol(const std::string& scheme); | 79 static bool IsHandledProtocol(const std::string& scheme); |
78 | 80 |
79 // Returns true if |url| is handled in Chrome, or by default handlers in | 81 // Returns true if |url| is handled in Chrome, or by default handlers in |
80 // net::URLRequest. | 82 // net::URLRequest. |
81 static bool IsHandledURL(const GURL& url); | 83 static bool IsHandledURL(const GURL& url); |
82 | 84 |
83 // Called by Profile. | 85 // Called by Profile. |
84 const content::ResourceContext& GetResourceContext() const; | 86 content::ResourceContext* GetResourceContext() const; |
85 ChromeURLDataManagerBackend* GetChromeURLDataManagerBackend() const; | 87 ChromeURLDataManagerBackend* GetChromeURLDataManagerBackend() const; |
86 | 88 |
87 // These should only be called at most once each. Ownership is reversed when | 89 // These should only be called at most once each. Ownership is reversed when |
88 // they get called, from ProfileIOData owning ChromeURLRequestContext to vice | 90 // they get called, from ProfileIOData owning ChromeURLRequestContext to vice |
89 // versa. | 91 // versa. |
90 scoped_refptr<ChromeURLRequestContext> GetMainRequestContext() const; | 92 scoped_refptr<ChromeURLRequestContext> GetMainRequestContext() const; |
91 scoped_refptr<ChromeURLRequestContext> GetMediaRequestContext() const; | 93 scoped_refptr<ChromeURLRequestContext> GetMediaRequestContext() const; |
92 scoped_refptr<ChromeURLRequestContext> GetExtensionsRequestContext() const; | 94 scoped_refptr<ChromeURLRequestContext> GetExtensionsRequestContext() const; |
93 scoped_refptr<ChromeURLRequestContext> GetIsolatedAppRequestContext( | 95 scoped_refptr<ChromeURLRequestContext> GetIsolatedAppRequestContext( |
94 scoped_refptr<ChromeURLRequestContext> main_context, | 96 scoped_refptr<ChromeURLRequestContext> main_context, |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 return job_factory_.get(); | 216 return job_factory_.get(); |
215 } | 217 } |
216 | 218 |
217 ChromeURLRequestContext* main_request_context() const { | 219 ChromeURLRequestContext* main_request_context() const { |
218 return main_request_context_; | 220 return main_request_context_; |
219 } | 221 } |
220 | 222 |
221 private: | 223 private: |
222 class ResourceContext : public content::ResourceContext { | 224 class ResourceContext : public content::ResourceContext { |
223 public: | 225 public: |
224 explicit ResourceContext(const ProfileIOData* io_data); | 226 explicit ResourceContext(ProfileIOData* io_data); |
225 virtual ~ResourceContext(); | 227 virtual ~ResourceContext(); |
226 | 228 |
227 private: | 229 private: |
228 virtual void EnsureInitialized() const OVERRIDE; | 230 friend class ProfileIOData; |
229 | 231 |
230 const ProfileIOData* const io_data_; | 232 // ResourceContext implementation: |
| 233 virtual net::HostResolver* GetHostResolver() OVERRIDE; |
| 234 virtual net::URLRequestContext* GetRequestContext() OVERRIDE; |
| 235 virtual ChromeAppCacheService* GetAppCacheService() OVERRIDE; |
| 236 virtual webkit_database::DatabaseTracker* GetDatabaseTracker() OVERRIDE; |
| 237 virtual fileapi::FileSystemContext* GetFileSystemContext() OVERRIDE; |
| 238 virtual ChromeBlobStorageContext* GetBlobStorageContext() OVERRIDE; |
| 239 virtual quota::QuotaManager* GetQuotaManager() OVERRIDE; |
| 240 virtual content::HostZoomMap* GetHostZoomMap() OVERRIDE; |
| 241 virtual MediaObserver* GetMediaObserver() OVERRIDE; |
| 242 virtual media_stream::MediaStreamManager* GetMediaStreamManager() OVERRIDE; |
| 243 virtual AudioManager* GetAudioManager() OVERRIDE; |
| 244 |
| 245 void EnsureInitialized(); |
| 246 |
| 247 ProfileIOData* const io_data_; |
| 248 |
| 249 net::HostResolver* host_resolver_; |
| 250 net::URLRequestContext* request_context_; |
| 251 ChromeAppCacheService* appcache_service_; |
| 252 webkit_database::DatabaseTracker* database_tracker_; |
| 253 fileapi::FileSystemContext* file_system_context_; |
| 254 ChromeBlobStorageContext* blob_storage_context_; |
| 255 quota::QuotaManager* quota_manager_; |
| 256 content::HostZoomMap* host_zoom_map_; |
| 257 MediaObserver* media_observer_; |
| 258 media_stream::MediaStreamManager* media_stream_manager_; |
| 259 AudioManager* audio_manager_; |
231 }; | 260 }; |
232 | 261 |
233 typedef base::hash_map<std::string, scoped_refptr<ChromeURLRequestContext> > | 262 typedef base::hash_map<std::string, scoped_refptr<ChromeURLRequestContext> > |
234 AppRequestContextMap; | 263 AppRequestContextMap; |
235 | 264 |
236 // -------------------------------------------- | 265 // -------------------------------------------- |
237 // Virtual interface for subtypes to implement: | 266 // Virtual interface for subtypes to implement: |
238 // -------------------------------------------- | 267 // -------------------------------------------- |
239 | 268 |
240 // Does the actual initialization of the ProfileIOData subtype. Subtypes | 269 // Does the actual initialization of the ProfileIOData subtype. Subtypes |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 // One AppRequestContext per isolated app. | 338 // One AppRequestContext per isolated app. |
310 mutable AppRequestContextMap app_request_context_map_; | 339 mutable AppRequestContextMap app_request_context_map_; |
311 | 340 |
312 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. | 341 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. |
313 bool initialized_on_UI_thread_; | 342 bool initialized_on_UI_thread_; |
314 | 343 |
315 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); | 344 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); |
316 }; | 345 }; |
317 | 346 |
318 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ | 347 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ |
OLD | NEW |