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

Side by Side Diff: chrome/browser/extensions/extension_data_deleter.cc

Issue 9419033: Move creation of BrowserContext objects that live in content to content, instead of depending on th… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Fix memory leaks in tests Created 8 years, 10 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 | Annotate | Revision Log
OLDNEW
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 "chrome/browser/extensions/extension_data_deleter.h" 5 #include "chrome/browser/extensions/extension_data_deleter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/settings/settings_frontend.h" 11 #include "chrome/browser/extensions/settings/settings_frontend.h"
12 #include "chrome/common/chrome_constants.h" 12 #include "chrome/common/chrome_constants.h"
13 #include "chrome/common/extensions/extension.h" 13 #include "chrome/common/extensions/extension.h"
14 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
15 #include "content/browser/appcache/chrome_appcache_service.h" 15 #include "content/browser/appcache/chrome_appcache_service.h"
16 #include "content/browser/in_process_webkit/webkit_context.h" 16 #include "content/browser/in_process_webkit/webkit_context.h"
17 #include "net/base/completion_callback.h" 17 #include "net/base/completion_callback.h"
18 #include "net/base/cookie_monster.h" 18 #include "net/base/cookie_monster.h"
19 #include "net/base/net_errors.h" 19 #include "net/base/net_errors.h"
20 #include "net/url_request/url_request_context.h" 20 #include "net/url_request/url_request_context.h"
21 #include "net/url_request/url_request_context_getter.h" 21 #include "net/url_request/url_request_context_getter.h"
22 #include "webkit/database/database_tracker.h" 22 #include "webkit/database/database_tracker.h"
23 #include "webkit/database/database_util.h" 23 #include "webkit/database/database_util.h"
24 #include "webkit/fileapi/file_system_context.h" 24 #include "webkit/fileapi/file_system_context.h"
25 25
26 using content::BrowserContext;
26 using content::BrowserThread; 27 using content::BrowserThread;
27 28
28 // static 29 // static
29 void ExtensionDataDeleter::StartDeleting( 30 void ExtensionDataDeleter::StartDeleting(
30 Profile* profile, 31 Profile* profile,
31 const std::string& extension_id, 32 const std::string& extension_id,
32 const GURL& storage_origin, 33 const GURL& storage_origin,
33 bool is_storage_isolated) { 34 bool is_storage_isolated) {
34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
35 DCHECK(profile); 36 DCHECK(profile);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 profile->GetExtensionService()->settings_frontend()-> 71 profile->GetExtensionService()->settings_frontend()->
71 DeleteStorageSoon(extension_id); 72 DeleteStorageSoon(extension_id);
72 } 73 }
73 74
74 ExtensionDataDeleter::ExtensionDataDeleter( 75 ExtensionDataDeleter::ExtensionDataDeleter(
75 Profile* profile, 76 Profile* profile,
76 const std::string& extension_id, 77 const std::string& extension_id,
77 const GURL& storage_origin, 78 const GURL& storage_origin,
78 bool is_storage_isolated) 79 bool is_storage_isolated)
79 : extension_id_(extension_id) { 80 : extension_id_(extension_id) {
80 appcache_service_ = profile->GetAppCacheService(); 81 appcache_service_ = BrowserContext::GetAppCacheService(profile);
81 webkit_context_ = profile->GetWebKitContext(); 82 webkit_context_ = BrowserContext::GetWebKitContext(profile);
82 database_tracker_ = profile->GetDatabaseTracker(); 83 database_tracker_ = BrowserContext::GetDatabaseTracker(profile);
83 // Pick the right request context depending on whether it's an extension, 84 // Pick the right request context depending on whether it's an extension,
84 // isolated app, or regular app. 85 // isolated app, or regular app.
85 if (storage_origin.SchemeIs(chrome::kExtensionScheme)) { 86 if (storage_origin.SchemeIs(chrome::kExtensionScheme)) {
86 extension_request_context_ = profile->GetRequestContextForExtensions(); 87 extension_request_context_ = profile->GetRequestContextForExtensions();
87 } else if (is_storage_isolated) { 88 } else if (is_storage_isolated) {
88 extension_request_context_ = 89 extension_request_context_ =
89 profile->GetRequestContextForIsolatedApp(extension_id); 90 profile->GetRequestContextForIsolatedApp(extension_id);
90 isolated_app_path_ = profile->GetPath(). 91 isolated_app_path_ = profile->GetPath().
91 Append(chrome::kIsolatedAppStateDirname).AppendASCII(extension_id); 92 Append(chrome::kIsolatedAppStateDirname).AppendASCII(extension_id);
92 } else { 93 } else {
93 extension_request_context_ = profile->GetRequestContext(); 94 extension_request_context_ = profile->GetRequestContext();
94 } 95 }
95 file_system_context_ = profile->GetFileSystemContext(); 96 file_system_context_ = BrowserContext::GetFileSystemContext(profile);
96 storage_origin_ = storage_origin; 97 storage_origin_ = storage_origin;
97 origin_id_ = 98 origin_id_ =
98 webkit_database::DatabaseUtil::GetOriginIdentifier(storage_origin_); 99 webkit_database::DatabaseUtil::GetOriginIdentifier(storage_origin_);
99 } 100 }
100 101
101 ExtensionDataDeleter::~ExtensionDataDeleter() { 102 ExtensionDataDeleter::~ExtensionDataDeleter() {
102 } 103 }
103 104
104 void ExtensionDataDeleter::DeleteCookiesOnIOThread() { 105 void ExtensionDataDeleter::DeleteCookiesOnIOThread() {
105 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 106 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 // See http://crbug.com/85127 140 // See http://crbug.com/85127
140 if (!isolated_app_path_.empty()) 141 if (!isolated_app_path_.empty())
141 file_util::Delete(isolated_app_path_, true); 142 file_util::Delete(isolated_app_path_, true);
142 } 143 }
143 144
144 void ExtensionDataDeleter::DeleteAppcachesOnIOThread() { 145 void ExtensionDataDeleter::DeleteAppcachesOnIOThread() {
145 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
146 appcache_service_->DeleteAppCachesForOrigin( 147 appcache_service_->DeleteAppCachesForOrigin(
147 storage_origin_, net::CompletionCallback()); 148 storage_origin_, net::CompletionCallback());
148 } 149 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698