1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CONTENT_PUBLIC_BROWSER_APPCACHE_SERVICE_H_ 6 #define CONTENT_PUBLIC_BROWSER_APPCACHE_SERVICE_H_ 7 8 #include <map> 9 #include <set> 10 11 #include "base/memory/ref_counted.h" 12 #include "base/memory/scoped_ptr.h" 13 #include "content/common/content_export.h" 14 #include "content/public/common/appcache_info.h" 15 #include "net/base/completion_callback.h" 16 17 namespace content { 18 19 class AppCacheStorage; 20 21 // Refcounted container to avoid copying the collection in callbacks. 22 struct CONTENT_EXPORT AppCacheInfoCollection 23 : public base::RefCountedThreadSafe<AppCacheInfoCollection> { 24 AppCacheInfoCollection(); 25 26 std::map<GURL, AppCacheInfoVector> infos_by_origin; 27 28 private: 29 friend class base::RefCountedThreadSafe<AppCacheInfoCollection>; 30 virtual ~AppCacheInfoCollection(); 31 }; 32 33 // Exposes a limited interface to the AppCacheService. 34 // Call these methods only on the IO thread. 35 class CONTENT_EXPORT AppCacheService { 36 public: 37 // Determines if a request for 'url' can be satisfied while offline. 38 // This method always completes asynchronously. 39 virtual void CanHandleMainResourceOffline(const GURL& url, 40 const GURL& first_party, 41 const net::CompletionCallback& 42 callback) = 0; 43 44 // Populates 'collection' with info about all of the appcaches stored 45 // within the service, 'callback' is invoked upon completion. The service 46 // acquires a reference to the 'collection' until until completion. 47 // This method always completes asynchronously. 48 virtual void GetAllAppCacheInfo(AppCacheInfoCollection* collection, 49 const net::CompletionCallback& callback) = 0; 50 51 // Deletes the group identified by 'manifest_url', 'callback' is 52 // invoked upon completion. Upon completion, the cache group and 53 // any resources within the group are no longer loadable and all 54 // subresource loads for pages associated with a deleted group 55 // will fail. This method always completes asynchronously. 56 virtual void DeleteAppCacheGroup(const GURL& manifest_url, 57 const net::CompletionCallback& callback) = 0; 58 59 protected: ~AppCacheService()60 virtual ~AppCacheService() {} 61 }; 62 63 } // namespace content 64 65 #endif // CONTENT_PUBLIC_BROWSER_APPCACHE_SERVICE_H_ 66