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 #include "content/browser/appcache/chrome_appcache_service.h" | 5 #include "content/browser/appcache/chrome_appcache_service.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "content/browser/content_browser_client.h" | 9 #include "content/browser/content_browser_client.h" |
10 #include "content/common/notification_service.h" | 10 #include "content/common/notification_service.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
45 | 45 |
46 if (!has_initialized_thread_ids) { | 46 if (!has_initialized_thread_ids) { |
47 has_initialized_thread_ids = true; | 47 has_initialized_thread_ids = true; |
48 appcache::AppCacheThread::Init(BrowserThread::DB, BrowserThread::IO); | 48 appcache::AppCacheThread::Init(BrowserThread::DB, BrowserThread::IO); |
49 } | 49 } |
50 | 50 |
51 cache_path_ = cache_path; | 51 cache_path_ = cache_path; |
52 resource_context_ = resource_context; | 52 resource_context_ = resource_context; |
53 registrar_.Add( | 53 registrar_.Add( |
54 this, NotificationType::PURGE_MEMORY, NotificationService::AllSources()); | 54 this, content::NOTIFICATION_PURGE_MEMORY, |
| 55 NotificationService::AllSources()); |
55 SetClearLocalStateOnExit(clear_local_state_on_exit); | 56 SetClearLocalStateOnExit(clear_local_state_on_exit); |
56 | 57 |
57 // Init our base class. | 58 // Init our base class. |
58 Initialize(cache_path_, | 59 Initialize(cache_path_, |
59 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)); | 60 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)); |
60 set_appcache_policy(this); | 61 set_appcache_policy(this); |
61 set_special_storage_policy(special_storage_policy); | 62 set_special_storage_policy(special_storage_policy); |
62 } | 63 } |
63 | 64 |
64 ChromeAppCacheService::~ChromeAppCacheService() { | 65 ChromeAppCacheService::~ChromeAppCacheService() { |
(...skipping 26 matching lines...) Expand all Loading... |
91 manifest_url, *resource_context_); | 92 manifest_url, *resource_context_); |
92 } | 93 } |
93 | 94 |
94 int ChromeAppCacheService::CanCreateAppCache( | 95 int ChromeAppCacheService::CanCreateAppCache( |
95 const GURL& manifest_url, net::CompletionCallback* callback) { | 96 const GURL& manifest_url, net::CompletionCallback* callback) { |
96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
97 return content::GetContentClient()->browser()->AllowAppCache( | 98 return content::GetContentClient()->browser()->AllowAppCache( |
98 manifest_url, *resource_context_) ? net::OK : net::ERR_ACCESS_DENIED; | 99 manifest_url, *resource_context_) ? net::OK : net::ERR_ACCESS_DENIED; |
99 } | 100 } |
100 | 101 |
101 void ChromeAppCacheService::Observe(NotificationType type, | 102 void ChromeAppCacheService::Observe(int type, |
102 const NotificationSource& source, | 103 const NotificationSource& source, |
103 const NotificationDetails& details) { | 104 const NotificationDetails& details) { |
104 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 105 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
105 DCHECK(type == NotificationType::PURGE_MEMORY); | 106 DCHECK(type == content::NOTIFICATION_PURGE_MEMORY); |
106 PurgeMemory(); | 107 PurgeMemory(); |
107 } | 108 } |
108 | 109 |
109 // ---------------------------------------------------------------------------- | 110 // ---------------------------------------------------------------------------- |
110 | 111 |
111 static BrowserThread::ID ToBrowserThreadID(int id) { | 112 static BrowserThread::ID ToBrowserThreadID(int id) { |
112 DCHECK(has_initialized_thread_ids); | 113 DCHECK(has_initialized_thread_ids); |
113 DCHECK(id == BrowserThread::DB || id == BrowserThread::IO); | 114 DCHECK(id == BrowserThread::DB || id == BrowserThread::IO); |
114 return static_cast<BrowserThread::ID>(id); | 115 return static_cast<BrowserThread::ID>(id); |
115 } | 116 } |
116 | 117 |
117 namespace appcache { | 118 namespace appcache { |
118 | 119 |
119 // An impl of AppCacheThread we need to provide to the appcache lib. | 120 // An impl of AppCacheThread we need to provide to the appcache lib. |
120 | 121 |
121 bool AppCacheThread::PostTask( | 122 bool AppCacheThread::PostTask( |
122 int id, | 123 int id, |
123 const tracked_objects::Location& from_here, | 124 const tracked_objects::Location& from_here, |
124 Task* task) { | 125 Task* task) { |
125 return BrowserThread::PostTask(ToBrowserThreadID(id), from_here, task); | 126 return BrowserThread::PostTask(ToBrowserThreadID(id), from_here, task); |
126 } | 127 } |
127 | 128 |
128 bool AppCacheThread::CurrentlyOn(int id) { | 129 bool AppCacheThread::CurrentlyOn(int id) { |
129 return BrowserThread::CurrentlyOn(ToBrowserThreadID(id)); | 130 return BrowserThread::CurrentlyOn(ToBrowserThreadID(id)); |
130 } | 131 } |
131 | 132 |
132 } // namespace appcache | 133 } // namespace appcache |
OLD | NEW |