OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "content/browser/resource_context_impl.h" | 5 #include "content/browser/resource_context_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/browser/appcache/chrome_appcache_service.h" | |
9 #include "content/browser/fileapi/browser_file_system_helper.h" | 8 #include "content/browser/fileapi/browser_file_system_helper.h" |
10 #include "content/browser/fileapi/chrome_blob_storage_context.h" | 9 #include "content/browser/fileapi/chrome_blob_storage_context.h" |
11 #include "content/browser/histogram_internals_request_job.h" | 10 #include "content/browser/histogram_internals_request_job.h" |
12 #include "content/browser/host_zoom_map_impl.h" | 11 #include "content/browser/host_zoom_map_impl.h" |
13 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" | 12 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" |
14 #include "content/browser/net/view_blob_internals_job_factory.h" | 13 #include "content/browser/net/view_blob_internals_job_factory.h" |
15 #include "content/browser/net/view_http_cache_job_factory.h" | 14 #include "content/browser/net/view_http_cache_job_factory.h" |
16 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" | 15 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" |
17 #include "content/browser/renderer_host/resource_request_info_impl.h" | 16 #include "content/browser/renderer_host/resource_request_info_impl.h" |
18 #include "content/browser/tcmalloc_internals_request_job.h" | 17 #include "content/browser/tcmalloc_internals_request_job.h" |
19 #include "content/public/browser/browser_context.h" | 18 #include "content/public/browser/browser_context.h" |
20 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
21 #include "content/public/browser/storage_partition.h" | 20 #include "content/public/browser/storage_partition.h" |
22 #include "content/public/common/url_constants.h" | 21 #include "content/public/common/url_constants.h" |
23 #include "net/url_request/url_request.h" | 22 #include "net/url_request/url_request.h" |
24 #include "net/url_request/url_request_context.h" | 23 #include "net/url_request/url_request_context.h" |
25 #include "net/url_request/url_request_context_getter.h" | 24 #include "net/url_request/url_request_context_getter.h" |
26 #include "webkit/appcache/appcache_service.h" | |
27 #include "webkit/appcache/view_appcache_internals_job.h" | |
28 #include "webkit/blob/blob_data.h" | |
29 #include "webkit/blob/blob_url_request_job_factory.h" | |
30 #include "webkit/database/database_tracker.h" | |
31 #include "webkit/fileapi/file_system_url_request_job_factory.h" | |
32 | 25 |
33 // Key names on ResourceContext. | 26 // Key names on ResourceContext. |
34 static const char* kBlobStorageContextKeyName = "content_blob_storage_context"; | 27 static const char* kBlobStorageContextKeyName = "content_blob_storage_context"; |
35 static const char* kHostZoomMapKeyName = "content_host_zoom_map"; | 28 static const char* kHostZoomMapKeyName = "content_host_zoom_map"; |
36 | 29 |
37 using appcache::AppCacheService; | |
38 using base::UserDataAdapter; | 30 using base::UserDataAdapter; |
39 using content::BrowserThread; | 31 using content::BrowserThread; |
40 using fileapi::FileSystemContext; | |
41 using webkit_blob::BlobStorageController; | |
42 using webkit_database::DatabaseTracker; | |
43 | 32 |
44 namespace content { | 33 namespace content { |
45 | 34 |
46 namespace { | 35 namespace { |
47 | 36 |
48 class NonOwningZoomData : public base::SupportsUserData::Data { | 37 class NonOwningZoomData : public base::SupportsUserData::Data { |
49 public: | 38 public: |
50 explicit NonOwningZoomData(HostZoomMap* hzm) : host_zoom_map_(hzm) {} | 39 explicit NonOwningZoomData(HostZoomMap* hzm) : host_zoom_map_(hzm) {} |
51 HostZoomMap* host_zoom_map() { return host_zoom_map_; } | 40 HostZoomMap* host_zoom_map() { return host_zoom_map_; } |
52 | 41 |
53 private: | 42 private: |
54 HostZoomMap* host_zoom_map_; | 43 HostZoomMap* host_zoom_map_; |
55 }; | 44 }; |
56 | 45 |
57 } // namespace | 46 } // namespace |
58 | 47 |
59 | 48 |
60 ResourceContext::ResourceContext() { | |
61 if (ResourceDispatcherHostImpl::Get()) | |
62 ResourceDispatcherHostImpl::Get()->AddResourceContext(this); | |
63 } | |
64 | |
65 ResourceContext::~ResourceContext() { | |
66 ResourceDispatcherHostImpl* rdhi = ResourceDispatcherHostImpl::Get(); | |
67 if (rdhi) { | |
68 rdhi->CancelRequestsForContext(this); | |
69 rdhi->RemoveResourceContext(this); | |
70 } | |
71 } | |
72 | |
73 ChromeBlobStorageContext* GetChromeBlobStorageContextForResourceContext( | 49 ChromeBlobStorageContext* GetChromeBlobStorageContextForResourceContext( |
74 ResourceContext* resource_context) { | 50 ResourceContext* resource_context) { |
75 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
76 return UserDataAdapter<ChromeBlobStorageContext>::Get( | 52 return UserDataAdapter<ChromeBlobStorageContext>::Get( |
77 resource_context, kBlobStorageContextKeyName); | 53 resource_context, kBlobStorageContextKeyName); |
78 } | 54 } |
79 | 55 |
80 HostZoomMap* GetHostZoomMapForResourceContext(ResourceContext* context) { | 56 HostZoomMap* GetHostZoomMapForResourceContext(ResourceContext* context) { |
81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
82 return static_cast<NonOwningZoomData*>( | 58 return static_cast<NonOwningZoomData*>( |
(...skipping 12 matching lines...) Expand all Loading... |
95 // This object is owned by the BrowserContext and not ResourceContext, so | 71 // This object is owned by the BrowserContext and not ResourceContext, so |
96 // store a non-owning pointer here. | 72 // store a non-owning pointer here. |
97 resource_context->SetUserData( | 73 resource_context->SetUserData( |
98 kHostZoomMapKeyName, | 74 kHostZoomMapKeyName, |
99 new NonOwningZoomData( | 75 new NonOwningZoomData( |
100 HostZoomMap::GetForBrowserContext(browser_context))); | 76 HostZoomMap::GetForBrowserContext(browser_context))); |
101 resource_context->DetachUserDataThread(); | 77 resource_context->DetachUserDataThread(); |
102 } | 78 } |
103 | 79 |
104 } // namespace content | 80 } // namespace content |
OLD | NEW |