| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef WEBKIT_BROWSER_APPCACHE_APPCACHE_BACKEND_IMPL_H_ | |
| 6 #define WEBKIT_BROWSER_APPCACHE_APPCACHE_BACKEND_IMPL_H_ | |
| 7 | |
| 8 #include "base/containers/hash_tables.h" | |
| 9 #include "webkit/browser/appcache/appcache_host.h" | |
| 10 #include "webkit/browser/webkit_storage_browser_export.h" | |
| 11 | |
| 12 namespace appcache { | |
| 13 | |
| 14 class AppCacheServiceImpl; | |
| 15 | |
| 16 class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheBackendImpl { | |
| 17 public: | |
| 18 AppCacheBackendImpl(); | |
| 19 ~AppCacheBackendImpl(); | |
| 20 | |
| 21 void Initialize(AppCacheServiceImpl* service, | |
| 22 AppCacheFrontend* frontend, | |
| 23 int process_id); | |
| 24 | |
| 25 int process_id() const { return process_id_; } | |
| 26 | |
| 27 // Methods to support the AppCacheBackend interface. A false return | |
| 28 // value indicates an invalid host_id and that no action was taken | |
| 29 // by the backend impl. | |
| 30 bool RegisterHost(int host_id); | |
| 31 bool UnregisterHost(int host_id); | |
| 32 bool SetSpawningHostId(int host_id, int spawning_host_id); | |
| 33 bool SelectCache(int host_id, | |
| 34 const GURL& document_url, | |
| 35 const int64 cache_document_was_loaded_from, | |
| 36 const GURL& manifest_url); | |
| 37 void GetResourceList( | |
| 38 int host_id, std::vector<AppCacheResourceInfo>* resource_infos); | |
| 39 bool SelectCacheForWorker(int host_id, int parent_process_id, | |
| 40 int parent_host_id); | |
| 41 bool SelectCacheForSharedWorker(int host_id, int64 appcache_id); | |
| 42 bool MarkAsForeignEntry(int host_id, const GURL& document_url, | |
| 43 int64 cache_document_was_loaded_from); | |
| 44 bool GetStatusWithCallback(int host_id, const GetStatusCallback& callback, | |
| 45 void* callback_param); | |
| 46 bool StartUpdateWithCallback(int host_id, const StartUpdateCallback& callback, | |
| 47 void* callback_param); | |
| 48 bool SwapCacheWithCallback(int host_id, const SwapCacheCallback& callback, | |
| 49 void* callback_param); | |
| 50 | |
| 51 // Returns a pointer to a registered host. The backend retains ownership. | |
| 52 AppCacheHost* GetHost(int host_id) { | |
| 53 HostMap::iterator it = hosts_.find(host_id); | |
| 54 return (it != hosts_.end()) ? (it->second) : NULL; | |
| 55 } | |
| 56 | |
| 57 typedef base::hash_map<int, AppCacheHost*> HostMap; | |
| 58 const HostMap& hosts() { return hosts_; } | |
| 59 | |
| 60 // Methods to support cross site navigations. Hosts are transferred | |
| 61 // from process to process accordingly, deparented from the old | |
| 62 // processes backend and reparented to the new. | |
| 63 scoped_ptr<AppCacheHost> TransferHostOut(int host_id); | |
| 64 void TransferHostIn(int new_host_id, scoped_ptr<AppCacheHost> host); | |
| 65 | |
| 66 private: | |
| 67 AppCacheServiceImpl* service_; | |
| 68 AppCacheFrontend* frontend_; | |
| 69 int process_id_; | |
| 70 HostMap hosts_; | |
| 71 }; | |
| 72 | |
| 73 } // namespace | |
| 74 | |
| 75 #endif // WEBKIT_BROWSER_APPCACHE_APPCACHE_BACKEND_IMPL_H_ | |
| OLD | NEW |