Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: chrome/browser/appcache/chrome_appcache_service.cc

Issue 3524012: Rename ChromeThread to BrowserThread Part 2: (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/autocomplete/history_contents_provider_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/appcache/chrome_appcache_service.h" 5 #include "chrome/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 "chrome/browser/browser_list.h" 9 #include "chrome/browser/browser_list.h"
10 #include "chrome/browser/net/chrome_url_request_context.h" 10 #include "chrome/browser/net/chrome_url_request_context.h"
11 #include "chrome/common/chrome_constants.h" 11 #include "chrome/common/chrome_constants.h"
12 #include "chrome/common/notification_service.h" 12 #include "chrome/common/notification_service.h"
13 #include "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
14 #include "webkit/appcache/appcache_thread.h" 14 #include "webkit/appcache/appcache_thread.h"
15 15
16 static bool has_initialized_thread_ids; 16 static bool has_initialized_thread_ids;
17 17
18 // ---------------------------------------------------------------------------- 18 // ----------------------------------------------------------------------------
19 19
20 ChromeAppCacheService::ChromeAppCacheService() { 20 ChromeAppCacheService::ChromeAppCacheService() {
21 } 21 }
22 22
23 void ChromeAppCacheService::InitializeOnIOThread( 23 void ChromeAppCacheService::InitializeOnIOThread(
24 const FilePath& profile_path, bool is_incognito, 24 const FilePath& profile_path, bool is_incognito,
25 scoped_refptr<HostContentSettingsMap> content_settings_map) { 25 scoped_refptr<HostContentSettingsMap> content_settings_map) {
26 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); 26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
27 27
28 if (!has_initialized_thread_ids) { 28 if (!has_initialized_thread_ids) {
29 has_initialized_thread_ids = true; 29 has_initialized_thread_ids = true;
30 appcache::AppCacheThread::Init(ChromeThread::DB, ChromeThread::IO); 30 appcache::AppCacheThread::Init(BrowserThread::DB, BrowserThread::IO);
31 } 31 }
32 32
33 host_contents_settings_map_ = content_settings_map; 33 host_contents_settings_map_ = content_settings_map;
34 registrar_.Add( 34 registrar_.Add(
35 this, NotificationType::PURGE_MEMORY, NotificationService::AllSources()); 35 this, NotificationType::PURGE_MEMORY, NotificationService::AllSources());
36 36
37 // Init our base class. 37 // Init our base class.
38 Initialize( 38 Initialize(
39 is_incognito ? FilePath() : profile_path.Append(chrome::kAppCacheDirname), 39 is_incognito ? FilePath() : profile_path.Append(chrome::kAppCacheDirname),
40 ChromeThread::GetMessageLoopProxyForThread(ChromeThread::CACHE)); 40 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE));
41 set_appcache_policy(this); 41 set_appcache_policy(this);
42 } 42 }
43 43
44 ChromeAppCacheService::~ChromeAppCacheService() { 44 ChromeAppCacheService::~ChromeAppCacheService() {
45 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
46 } 46 }
47 47
48 void ChromeAppCacheService::SetOriginQuotaInMemory( 48 void ChromeAppCacheService::SetOriginQuotaInMemory(
49 const GURL& origin, int64 quota) { 49 const GURL& origin, int64 quota) {
50 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); 50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
51 if (storage()) 51 if (storage())
52 storage()->SetOriginQuotaInMemory(origin, quota); 52 storage()->SetOriginQuotaInMemory(origin, quota);
53 } 53 }
54 54
55 void ChromeAppCacheService::ResetOriginQuotaInMemory(const GURL& origin) { 55 void ChromeAppCacheService::ResetOriginQuotaInMemory(const GURL& origin) {
56 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); 56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
57 if (storage()) 57 if (storage())
58 storage()->ResetOriginQuotaInMemory(origin); 58 storage()->ResetOriginQuotaInMemory(origin);
59 } 59 }
60 60
61 // static 61 // static
62 void ChromeAppCacheService::ClearLocalState(const FilePath& profile_path) { 62 void ChromeAppCacheService::ClearLocalState(const FilePath& profile_path) {
63 file_util::Delete(profile_path.Append(chrome::kAppCacheDirname), true); 63 file_util::Delete(profile_path.Append(chrome::kAppCacheDirname), true);
64 } 64 }
65 65
66 bool ChromeAppCacheService::CanLoadAppCache(const GURL& manifest_url) { 66 bool ChromeAppCacheService::CanLoadAppCache(const GURL& manifest_url) {
67 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); 67 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
68 ContentSetting setting = host_contents_settings_map_->GetContentSetting( 68 ContentSetting setting = host_contents_settings_map_->GetContentSetting(
69 manifest_url, CONTENT_SETTINGS_TYPE_COOKIES, ""); 69 manifest_url, CONTENT_SETTINGS_TYPE_COOKIES, "");
70 DCHECK(setting != CONTENT_SETTING_DEFAULT); 70 DCHECK(setting != CONTENT_SETTING_DEFAULT);
71 // We don't prompt for read access. 71 // We don't prompt for read access.
72 return setting != CONTENT_SETTING_BLOCK; 72 return setting != CONTENT_SETTING_BLOCK;
73 } 73 }
74 74
75 int ChromeAppCacheService::CanCreateAppCache( 75 int ChromeAppCacheService::CanCreateAppCache(
76 const GURL& manifest_url, net::CompletionCallback* callback) { 76 const GURL& manifest_url, net::CompletionCallback* callback) {
77 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); 77 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
78 ContentSetting setting = host_contents_settings_map_->GetContentSetting( 78 ContentSetting setting = host_contents_settings_map_->GetContentSetting(
79 manifest_url, CONTENT_SETTINGS_TYPE_COOKIES, ""); 79 manifest_url, CONTENT_SETTINGS_TYPE_COOKIES, "");
80 DCHECK(setting != CONTENT_SETTING_DEFAULT); 80 DCHECK(setting != CONTENT_SETTING_DEFAULT);
81 return (setting != CONTENT_SETTING_BLOCK) ? net::OK : 81 return (setting != CONTENT_SETTING_BLOCK) ? net::OK :
82 net::ERR_ACCESS_DENIED; 82 net::ERR_ACCESS_DENIED;
83 } 83 }
84 84
85 void ChromeAppCacheService::Observe(NotificationType type, 85 void ChromeAppCacheService::Observe(NotificationType type,
86 const NotificationSource& source, 86 const NotificationSource& source,
87 const NotificationDetails& details) { 87 const NotificationDetails& details) {
88 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); 88 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
89 DCHECK(type == NotificationType::PURGE_MEMORY); 89 DCHECK(type == NotificationType::PURGE_MEMORY);
90 PurgeMemory(); 90 PurgeMemory();
91 } 91 }
92 92
93 // ---------------------------------------------------------------------------- 93 // ----------------------------------------------------------------------------
94 94
95 static ChromeThread::ID ToChromeThreadID(int id) { 95 static BrowserThread::ID ToBrowserThreadID(int id) {
96 DCHECK(has_initialized_thread_ids); 96 DCHECK(has_initialized_thread_ids);
97 DCHECK(id == ChromeThread::DB || id == ChromeThread::IO); 97 DCHECK(id == BrowserThread::DB || id == BrowserThread::IO);
98 return static_cast<ChromeThread::ID>(id); 98 return static_cast<BrowserThread::ID>(id);
99 } 99 }
100 100
101 namespace appcache { 101 namespace appcache {
102 102
103 // An impl of AppCacheThread we need to provide to the appcache lib. 103 // An impl of AppCacheThread we need to provide to the appcache lib.
104 104
105 bool AppCacheThread::PostTask( 105 bool AppCacheThread::PostTask(
106 int id, 106 int id,
107 const tracked_objects::Location& from_here, 107 const tracked_objects::Location& from_here,
108 Task* task) { 108 Task* task) {
109 return ChromeThread::PostTask(ToChromeThreadID(id), from_here, task); 109 return BrowserThread::PostTask(ToBrowserThreadID(id), from_here, task);
110 } 110 }
111 111
112 bool AppCacheThread::CurrentlyOn(int id) { 112 bool AppCacheThread::CurrentlyOn(int id) {
113 return ChromeThread::CurrentlyOn(ToChromeThreadID(id)); 113 return BrowserThread::CurrentlyOn(ToBrowserThreadID(id));
114 } 114 }
115 115
116 } // namespace appcache 116 } // namespace appcache
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/autocomplete/history_contents_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698