blob: 4585b789038211e31b38e592721bf042f7f0ec3f [file] [log] [blame]
[email protected]e16b8af72011-03-21 22:11:421// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]f430b5712009-08-21 21:46:312// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]98d6d4562014-06-25 20:57:555#ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_BACKEND_IMPL_H_
6#define CONTENT_BROWSER_APPCACHE_APPCACHE_BACKEND_IMPL_H_
[email protected]f430b5712009-08-21 21:46:317
avib7348942015-12-25 20:57:108#include <stdint.h>
9
[email protected]14c1c232013-06-11 17:52:4410#include "base/containers/hash_tables.h"
[email protected]98d6d4562014-06-25 20:57:5511#include "content/browser/appcache/appcache_host.h"
12#include "content/common/content_export.h"
[email protected]f430b5712009-08-21 21:46:3113
[email protected]98d6d4562014-06-25 20:57:5514namespace content {
[email protected]f430b5712009-08-21 21:46:3115
[email protected]63ef85512014-06-05 14:21:2616class AppCacheServiceImpl;
[email protected]f430b5712009-08-21 21:46:3117
[email protected]98d6d4562014-06-25 20:57:5518class CONTENT_EXPORT AppCacheBackendImpl {
[email protected]f430b5712009-08-21 21:46:3119 public:
[email protected]20f0487a2010-09-30 20:06:3020 AppCacheBackendImpl();
[email protected]f430b5712009-08-21 21:46:3121 ~AppCacheBackendImpl();
22
[email protected]63ef85512014-06-05 14:21:2623 void Initialize(AppCacheServiceImpl* service,
[email protected]23f1ef12009-09-01 22:30:3024 AppCacheFrontend* frontend,
25 int process_id);
[email protected]f430b5712009-08-21 21:46:3126
[email protected]23f1ef12009-09-01 22:30:3027 int process_id() const { return process_id_; }
28
[email protected]97e3edc2009-09-15 22:07:1529 // Methods to support the AppCacheBackend interface. A false return
30 // value indicates an invalid host_id and that no action was taken
31 // by the backend impl.
32 bool RegisterHost(int host_id);
33 bool UnregisterHost(int host_id);
[email protected]e16b8af72011-03-21 22:11:4234 bool SetSpawningHostId(int host_id, int spawning_host_id);
[email protected]97e3edc2009-09-15 22:07:1535 bool SelectCache(int host_id,
36 const GURL& document_url,
avib7348942015-12-25 20:57:1037 const int64_t cache_document_was_loaded_from,
[email protected]97e3edc2009-09-15 22:07:1538 const GURL& manifest_url);
[email protected]ec5c1922010-07-28 03:14:3739 void GetResourceList(
40 int host_id, std::vector<AppCacheResourceInfo>* resource_infos);
[email protected]e5390a42010-05-27 22:43:1941 bool SelectCacheForWorker(int host_id, int parent_process_id,
42 int parent_host_id);
avib7348942015-12-25 20:57:1043 bool SelectCacheForSharedWorker(int host_id, int64_t appcache_id);
44 bool MarkAsForeignEntry(int host_id,
45 const GURL& document_url,
46 int64_t cache_document_was_loaded_from);
[email protected]2de55302011-10-10 22:09:5847 bool GetStatusWithCallback(int host_id, const GetStatusCallback& callback,
[email protected]97e3edc2009-09-15 22:07:1548 void* callback_param);
[email protected]2de55302011-10-10 22:09:5849 bool StartUpdateWithCallback(int host_id, const StartUpdateCallback& callback,
[email protected]97e3edc2009-09-15 22:07:1550 void* callback_param);
[email protected]2de55302011-10-10 22:09:5851 bool SwapCacheWithCallback(int host_id, const SwapCacheCallback& callback,
[email protected]97e3edc2009-09-15 22:07:1552 void* callback_param);
53
[email protected]23f1ef12009-09-01 22:30:3054 // Returns a pointer to a registered host. The backend retains ownership.
55 AppCacheHost* GetHost(int host_id) {
56 HostMap::iterator it = hosts_.find(host_id);
[email protected]97e3edc2009-09-15 22:07:1557 return (it != hosts_.end()) ? (it->second) : NULL;
[email protected]23f1ef12009-09-01 22:30:3058 }
59
[email protected]97e3edc2009-09-15 22:07:1560 typedef base::hash_map<int, AppCacheHost*> HostMap;
[email protected]23f1ef12009-09-01 22:30:3061 const HostMap& hosts() { return hosts_; }
62
[email protected]5fcb289e2014-02-04 00:34:1963 // Methods to support cross site navigations. Hosts are transferred
64 // from process to process accordingly, deparented from the old
65 // processes backend and reparented to the new.
dcheng59716272016-04-09 05:19:0866 std::unique_ptr<AppCacheHost> TransferHostOut(int host_id);
67 void TransferHostIn(int new_host_id, std::unique_ptr<AppCacheHost> host);
[email protected]5fcb289e2014-02-04 00:34:1968
[email protected]f430b5712009-08-21 21:46:3169 private:
[email protected]63ef85512014-06-05 14:21:2670 AppCacheServiceImpl* service_;
[email protected]f430b5712009-08-21 21:46:3171 AppCacheFrontend* frontend_;
[email protected]23f1ef12009-09-01 22:30:3072 int process_id_;
73 HostMap hosts_;
[email protected]f430b5712009-08-21 21:46:3174};
75
76} // namespace
77
[email protected]98d6d4562014-06-25 20:57:5578#endif // CONTENT_BROWSER_APPCACHE_APPCACHE_BACKEND_IMPL_H_