summaryrefslogtreecommitdiffstats
path: root/content/browser/appcache
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-20 17:38:39 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-20 17:38:39 +0000
commit55eb70e76bd17909cc5202c5a9af3e1c886989e4 (patch)
tree9ea8a13b9f9e1ab0297ea0ff79093dc4c5ad20d0 /content/browser/appcache
parent7edf30319847892be800a0127fee985a24050166 (diff)
downloadchromium_src-55eb70e76bd17909cc5202c5a9af3e1c886989e4.zip
chromium_src-55eb70e76bd17909cc5202c5a9af3e1c886989e4.tar.gz
chromium_src-55eb70e76bd17909cc5202c5a9af3e1c886989e4.tar.bz2
Move creation of BrowserContext objects that live in content to content, instead of depending on the embedder. Apart from allowing us to hide more of content from embedders, it simplifies the work that every embedder has to do (see the change the shell_browser_context.cc as an example).
BUG=98716 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=122521 Review URL: https://chromiumcodereview.appspot.com/9419033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122768 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/appcache')
-rw-r--r--content/browser/appcache/chrome_appcache_service.cc9
-rw-r--r--content/browser/appcache/chrome_appcache_service.h19
2 files changed, 21 insertions, 7 deletions
diff --git a/content/browser/appcache/chrome_appcache_service.cc b/content/browser/appcache/chrome_appcache_service.cc
index 2dbf2c8..9be6b05 100644
--- a/content/browser/appcache/chrome_appcache_service.cc
+++ b/content/browser/appcache/chrome_appcache_service.cc
@@ -45,6 +45,15 @@ void ChromeAppCacheService::InitializeOnIOThread(
ChromeAppCacheService::~ChromeAppCacheService() {
}
+void ChromeAppCacheService::DeleteOnCorrectThread() const {
+ if (BrowserThread::IsMessageLoopValid(BrowserThread::IO) &&
+ !BrowserThread::CurrentlyOn(BrowserThread::IO)) {
+ BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this);
+ return;
+ }
+ delete this;
+}
+
bool ChromeAppCacheService::CanLoadAppCache(const GURL& manifest_url,
const GURL& first_party) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
diff --git a/content/browser/appcache/chrome_appcache_service.h b/content/browser/appcache/chrome_appcache_service.h
index 8ba1430..c1bf134 100644
--- a/content/browser/appcache/chrome_appcache_service.h
+++ b/content/browser/appcache/chrome_appcache_service.h
@@ -23,6 +23,8 @@ namespace content {
class ResourceContext;
}
+struct ChromeAppCacheServiceDeleter;
+
// An AppCacheService subclass used by the chrome. There is an instance
// associated with each BrowserContext. This derivation adds refcounting
// semantics since a browser context has multiple URLRequestContexts which refer
@@ -36,12 +38,13 @@ class ResourceContext;
// to worry about clients calling AppCacheService methods.
class CONTENT_EXPORT ChromeAppCacheService
: public base::RefCountedThreadSafe<
- ChromeAppCacheService, content::BrowserThread::DeleteOnIOThread>,
+ ChromeAppCacheService, ChromeAppCacheServiceDeleter>,
NON_EXPORTED_BASE(public appcache::AppCacheService),
NON_EXPORTED_BASE(public appcache::AppCachePolicy),
public content::NotificationObserver {
public:
explicit ChromeAppCacheService(quota::QuotaManagerProxy* proxy);
+ virtual ~ChromeAppCacheService();
void InitializeOnIOThread(
const FilePath& cache_path, // may be empty to use in-memory structures
@@ -49,13 +52,9 @@ class CONTENT_EXPORT ChromeAppCacheService
scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy);
private:
- friend class base::RefCountedThreadSafe<
- ChromeAppCacheService,
- content::BrowserThread::DeleteOnIOThread>;
- friend class content::BrowserThread;
- friend class base::DeleteHelper<ChromeAppCacheService>;
+ friend struct ChromeAppCacheServiceDeleter;
- virtual ~ChromeAppCacheService();
+ void DeleteOnCorrectThread() const;
// AppCachePolicy overrides
virtual bool CanLoadAppCache(const GURL& manifest_url,
@@ -75,4 +74,10 @@ class CONTENT_EXPORT ChromeAppCacheService
DISALLOW_COPY_AND_ASSIGN(ChromeAppCacheService);
};
+struct ChromeAppCacheServiceDeleter {
+ static void Destruct(const ChromeAppCacheService* service) {
+ service->DeleteOnCorrectThread();
+ }
+};
+
#endif // CONTENT_BROWSER_APPCACHE_CHROME_APPCACHE_SERVICE_H_