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/fileapi/chrome_blob_storage_context.h" | 8 #include "content/browser/fileapi/chrome_blob_storage_context.h" |
9 #include "content/browser/host_zoom_map_impl.h" | 9 #include "content/browser/host_zoom_map_impl.h" |
10 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 10 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 87 |
88 StreamContext* GetStreamContextForResourceContext( | 88 StreamContext* GetStreamContextForResourceContext( |
89 ResourceContext* resource_context) { | 89 ResourceContext* resource_context) { |
90 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 90 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
91 return UserDataAdapter<StreamContext>::Get( | 91 return UserDataAdapter<StreamContext>::Get( |
92 resource_context, kStreamContextKeyName); | 92 resource_context, kStreamContextKeyName); |
93 } | 93 } |
94 | 94 |
95 HostZoomMap* GetHostZoomMapForResourceContext(ResourceContext* context) { | 95 HostZoomMap* GetHostZoomMapForResourceContext(ResourceContext* context) { |
96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
97 return static_cast<NonOwningZoomData*>( | 97 NonOwningZoomData* result = static_cast<NonOwningZoomData*>( |
98 context->GetUserData(kHostZoomMapKeyName))->host_zoom_map(); | 98 context->GetUserData(kHostZoomMapKeyName)); |
| 99 if (!result) |
| 100 return NULL; |
| 101 return result->host_zoom_map(); |
99 } | 102 } |
100 | 103 |
101 URLDataManagerBackend* GetURLDataManagerForResourceContext( | 104 URLDataManagerBackend* GetURLDataManagerForResourceContext( |
102 ResourceContext* context) { | 105 ResourceContext* context) { |
103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 106 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
104 if (!context->GetUserData(kURLDataManagerBackendKeyName)) { | 107 if (!context->GetUserData(kURLDataManagerBackendKeyName)) { |
105 context->SetUserData(kURLDataManagerBackendKeyName, | 108 context->SetUserData(kURLDataManagerBackendKeyName, |
106 new URLDataManagerBackend()); | 109 new URLDataManagerBackend()); |
107 } | 110 } |
108 return static_cast<URLDataManagerBackend*>( | 111 return static_cast<URLDataManagerBackend*>( |
(...skipping 18 matching lines...) Expand all Loading... |
127 // store a non-owning pointer here. | 130 // store a non-owning pointer here. |
128 resource_context->SetUserData( | 131 resource_context->SetUserData( |
129 kHostZoomMapKeyName, | 132 kHostZoomMapKeyName, |
130 new NonOwningZoomData( | 133 new NonOwningZoomData( |
131 HostZoomMap::GetForBrowserContext(browser_context))); | 134 HostZoomMap::GetForBrowserContext(browser_context))); |
132 | 135 |
133 resource_context->DetachUserDataThread(); | 136 resource_context->DetachUserDataThread(); |
134 } | 137 } |
135 | 138 |
136 } // namespace content | 139 } // namespace content |
OLD | NEW |