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

Side by Side Diff: content/browser/appcache/chrome_appcache_service.h

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 #ifndef CONTENT_BROWSER_APPCACHE_CHROME_APPCACHE_SERVICE_H_ 5 #ifndef CONTENT_BROWSER_APPCACHE_CHROME_APPCACHE_SERVICE_H_
6 #define CONTENT_BROWSER_APPCACHE_CHROME_APPCACHE_SERVICE_H_ 6 #define CONTENT_BROWSER_APPCACHE_CHROME_APPCACHE_SERVICE_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/message_loop_helpers.h" 11 #include "base/message_loop_helpers.h"
12 #include "content/common/content_export.h" 12 #include "content/common/content_export.h"
13 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/notification_observer.h" 14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h" 15 #include "content/public/browser/notification_registrar.h"
16 #include "webkit/appcache/appcache_policy.h" 16 #include "webkit/appcache/appcache_policy.h"
17 #include "webkit/appcache/appcache_service.h" 17 #include "webkit/appcache/appcache_service.h"
18 #include "webkit/quota/special_storage_policy.h" 18 #include "webkit/quota/special_storage_policy.h"
19 19
20 class FilePath; 20 class FilePath;
21 21
22 namespace content { 22 namespace content {
23 class ResourceContext; 23 class ResourceContext;
24 } 24 }
25 25
26 struct ChromeAppCacheServiceDeleter;
27
26 // An AppCacheService subclass used by the chrome. There is an instance 28 // An AppCacheService subclass used by the chrome. There is an instance
27 // associated with each BrowserContext. This derivation adds refcounting 29 // associated with each BrowserContext. This derivation adds refcounting
28 // semantics since a browser context has multiple URLRequestContexts which refer 30 // semantics since a browser context has multiple URLRequestContexts which refer
29 // to the same object, and those URLRequestContexts are refcounted independently 31 // to the same object, and those URLRequestContexts are refcounted independently
30 // of the owning browser context. 32 // of the owning browser context.
31 // 33 //
32 // All methods, except the ctor, are expected to be called on 34 // All methods, except the ctor, are expected to be called on
33 // the IO thread (unless specifically called out in doc comments). 35 // the IO thread (unless specifically called out in doc comments).
34 // 36 //
35 // TODO(dpranke): Fix dependencies on AppCacheService so that we don't have 37 // TODO(dpranke): Fix dependencies on AppCacheService so that we don't have
36 // to worry about clients calling AppCacheService methods. 38 // to worry about clients calling AppCacheService methods.
37 class CONTENT_EXPORT ChromeAppCacheService 39 class CONTENT_EXPORT ChromeAppCacheService
38 : public base::RefCountedThreadSafe< 40 : public base::RefCountedThreadSafe<
39 ChromeAppCacheService, content::BrowserThread::DeleteOnIOThread>, 41 ChromeAppCacheService, ChromeAppCacheServiceDeleter>,
40 NON_EXPORTED_BASE(public appcache::AppCacheService), 42 NON_EXPORTED_BASE(public appcache::AppCacheService),
41 NON_EXPORTED_BASE(public appcache::AppCachePolicy), 43 NON_EXPORTED_BASE(public appcache::AppCachePolicy),
42 public content::NotificationObserver { 44 public content::NotificationObserver {
43 public: 45 public:
44 explicit ChromeAppCacheService(quota::QuotaManagerProxy* proxy); 46 explicit ChromeAppCacheService(quota::QuotaManagerProxy* proxy);
47 virtual ~ChromeAppCacheService();
45 48
46 void InitializeOnIOThread( 49 void InitializeOnIOThread(
47 const FilePath& cache_path, // may be empty to use in-memory structures 50 const FilePath& cache_path, // may be empty to use in-memory structures
48 content::ResourceContext* resource_context, 51 content::ResourceContext* resource_context,
49 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy); 52 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy);
50 53
51 private: 54 private:
52 friend class base::RefCountedThreadSafe< 55 friend struct ChromeAppCacheServiceDeleter;
53 ChromeAppCacheService,
54 content::BrowserThread::DeleteOnIOThread>;
55 friend class content::BrowserThread;
56 friend class base::DeleteHelper<ChromeAppCacheService>;
57 56
58 virtual ~ChromeAppCacheService(); 57 void DeleteOnCorrectThread() const;
59 58
60 // AppCachePolicy overrides 59 // AppCachePolicy overrides
61 virtual bool CanLoadAppCache(const GURL& manifest_url, 60 virtual bool CanLoadAppCache(const GURL& manifest_url,
62 const GURL& first_party) OVERRIDE; 61 const GURL& first_party) OVERRIDE;
63 virtual bool CanCreateAppCache(const GURL& manifest_url, 62 virtual bool CanCreateAppCache(const GURL& manifest_url,
64 const GURL& first_party) OVERRIDE; 63 const GURL& first_party) OVERRIDE;
65 64
66 // content::NotificationObserver override 65 // content::NotificationObserver override
67 virtual void Observe(int type, 66 virtual void Observe(int type,
68 const content::NotificationSource& source, 67 const content::NotificationSource& source,
69 const content::NotificationDetails& details) OVERRIDE; 68 const content::NotificationDetails& details) OVERRIDE;
70 69
71 content::ResourceContext* resource_context_; 70 content::ResourceContext* resource_context_;
72 content::NotificationRegistrar registrar_; 71 content::NotificationRegistrar registrar_;
73 FilePath cache_path_; 72 FilePath cache_path_;
74 73
75 DISALLOW_COPY_AND_ASSIGN(ChromeAppCacheService); 74 DISALLOW_COPY_AND_ASSIGN(ChromeAppCacheService);
76 }; 75 };
77 76
77 struct ChromeAppCacheServiceDeleter {
78 static void Destruct(const ChromeAppCacheService* service) {
79 service->DeleteOnCorrectThread();
80 }
81 };
82
78 #endif // CONTENT_BROWSER_APPCACHE_CHROME_APPCACHE_SERVICE_H_ 83 #endif // CONTENT_BROWSER_APPCACHE_CHROME_APPCACHE_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/test/base/testing_profile.cc ('k') | content/browser/appcache/chrome_appcache_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698