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

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

Issue 7210006: AppCaches which belong to hosted apps are not protected from deletion (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Minor. Created 9 years, 5 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/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/synchronization/waitable_event.h"
10 #include "content/browser/browser_thread.h" 11 #include "content/browser/browser_thread.h"
11 #include "content/common/notification_observer.h" 12 #include "content/common/notification_observer.h"
12 #include "content/common/notification_registrar.h" 13 #include "content/common/notification_registrar.h"
14 #include "net/base/completion_callback.h"
13 #include "webkit/appcache/appcache_policy.h" 15 #include "webkit/appcache/appcache_policy.h"
14 #include "webkit/appcache/appcache_service.h" 16 #include "webkit/appcache/appcache_service.h"
15 #include "webkit/quota/special_storage_policy.h" 17 #include "webkit/quota/special_storage_policy.h"
16 18
17 class FilePath; 19 class FilePath;
18 20
21 namespace appcache {
22 class TestableChromeAppCacheService;
23 }
24
19 namespace content { 25 namespace content {
20 class ResourceContext; 26 class ResourceContext;
21 } 27 }
22 28
23 // An AppCacheService subclass used by the chrome. There is an instance 29 // An AppCacheService subclass used by the chrome. There is an instance
24 // associated with each Profile. This derivation adds refcounting semantics 30 // associated with each Profile. This derivation adds refcounting semantics
25 // since a profile has multiple URLRequestContexts which refer to the same 31 // since a profile has multiple URLRequestContexts which refer to the same
26 // object, and those URLRequestContexts are refcounted independently of the 32 // object, and those URLRequestContexts are refcounted independently of the
27 // owning profile. 33 // owning profile.
28 // 34 //
29 // All methods, except the ctor, are expected to be called on 35 // All methods, except the ctor, are expected to be called on
30 // the IO thread (unless specifically called out in doc comments). 36 // the IO thread (unless specifically called out in doc comments).
31 class ChromeAppCacheService 37 class ChromeAppCacheService
32 : public base::RefCountedThreadSafe<ChromeAppCacheService, 38 : public base::RefCountedThreadSafe<ChromeAppCacheService,
33 BrowserThread::DeleteOnIOThread>, 39 BrowserThread::DeleteOnIOThread>,
34 public appcache::AppCacheService, 40 public appcache::AppCacheService,
35 public appcache::AppCachePolicy, 41 public appcache::AppCachePolicy,
36 public NotificationObserver { 42 public NotificationObserver {
37 public: 43 public:
38 explicit ChromeAppCacheService(quota::QuotaManagerProxy* proxy); 44 explicit ChromeAppCacheService(quota::QuotaManagerProxy* proxy);
39 45
40 void InitializeOnIOThread( 46 void InitializeOnIOThread(
41 const FilePath& cache_path, // may be empty to use in-memory structures 47 const FilePath& cache_path, // may be empty to use in-memory structures
42 const content::ResourceContext* resource_context, 48 const content::ResourceContext* resource_context,
43 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, 49 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy);
44 bool clear_local_state_on_exit);
45 50
46 void SetClearLocalStateOnExit(bool clear_local_state); 51 // Safe to call from any thread
52 base::WaitableEvent* ClearAppCache(net::CompletionCallback* callback);
michaeln 2011/07/14 22:53:16 If we don't make the changes to the BDR in this CL
marja(google) 2011/07/15 11:03:42 Done.
47 53
48 private: 54 private:
49 friend class BrowserThread; 55 friend class BrowserThread;
50 friend class DeleteTask<ChromeAppCacheService>; 56 friend class DeleteTask<ChromeAppCacheService>;
57 friend class appcache::TestableChromeAppCacheService;
51 58
52 virtual ~ChromeAppCacheService(); 59 virtual ~ChromeAppCacheService();
53 60
54 // AppCachePolicy overrides 61 // AppCachePolicy overrides
55 virtual bool CanLoadAppCache(const GURL& manifest_url); 62 virtual bool CanLoadAppCache(const GURL& manifest_url);
56 virtual int CanCreateAppCache(const GURL& manifest_url, 63 virtual int CanCreateAppCache(const GURL& manifest_url,
57 net::CompletionCallback* callback); 64 net::CompletionCallback* callback);
58 65
59 // NotificationObserver override 66 // NotificationObserver override
60 virtual void Observe(int type, 67 virtual void Observe(int type,
61 const NotificationSource& source, 68 const NotificationSource& source,
62 const NotificationDetails& details); 69 const NotificationDetails& details);
63 70
71 // AppCache clearing helpers and callbacks
72 void OnGotAppCacheInfo(int rv);
73 void OnAppCacheDeleted(int rv);
74 void OnClearedAppCache();
75
64 const content::ResourceContext* resource_context_; 76 const content::ResourceContext* resource_context_;
65 NotificationRegistrar registrar_; 77 NotificationRegistrar registrar_;
66 bool clear_local_state_on_exit_;
67 FilePath cache_path_; 78 FilePath cache_path_;
79 net::CompletionCallbackImpl<ChromeAppCacheService>
80 appcache_got_info_callback_;
81 net::CompletionCallbackImpl<ChromeAppCacheService>
82 appcache_deleted_callback_;
83 scoped_refptr<appcache::AppCacheInfoCollection> appcache_info_;
84 int appcaches_to_be_deleted_count_;
85 scoped_ptr<base::WaitableEvent> appcaches_cleared_event_;
86 net::CompletionCallback* appcaches_cleared_callback_;
87 bool waiting_for_clear_appcaches_;
68 88
69 DISALLOW_COPY_AND_ASSIGN(ChromeAppCacheService); 89 DISALLOW_COPY_AND_ASSIGN(ChromeAppCacheService);
70 }; 90 };
71 91
72 #endif // CONTENT_BROWSER_APPCACHE_CHROME_APPCACHE_SERVICE_H_ 92 #endif // CONTENT_BROWSER_APPCACHE_CHROME_APPCACHE_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698