Dismiss autofill popup on screen orientation change.
[chromium-blink-merge.git] / webkit / browser / appcache / appcache_backend_impl.cc
blobfd8029d6dab7b5561d965c5349b24675b8fc8015
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.
5 #include "webkit/browser/appcache/appcache_backend_impl.h"
7 #include "base/stl_util.h"
8 #include "webkit/browser/appcache/appcache.h"
9 #include "webkit/browser/appcache/appcache_group.h"
10 #include "webkit/browser/appcache/appcache_service.h"
12 namespace appcache {
14 AppCacheBackendImpl::AppCacheBackendImpl()
15 : service_(NULL),
16 frontend_(NULL),
17 process_id_(0) {
20 AppCacheBackendImpl::~AppCacheBackendImpl() {
21 STLDeleteValues(&hosts_);
22 if (service_)
23 service_->UnregisterBackend(this);
26 void AppCacheBackendImpl::Initialize(AppCacheService* service,
27 AppCacheFrontend* frontend,
28 int process_id) {
29 DCHECK(!service_ && !frontend_ && frontend && service);
30 service_ = service;
31 frontend_ = frontend;
32 process_id_ = process_id;
33 service_->RegisterBackend(this);
36 bool AppCacheBackendImpl::RegisterHost(int id) {
37 if (GetHost(id))
38 return false;
40 hosts_.insert(
41 HostMap::value_type(id, new AppCacheHost(id, frontend_, service_)));
42 return true;
45 bool AppCacheBackendImpl::UnregisterHost(int id) {
46 HostMap::iterator found = hosts_.find(id);
47 if (found == hosts_.end())
48 return false;
50 delete found->second;
51 hosts_.erase(found);
52 return true;
55 bool AppCacheBackendImpl::SetSpawningHostId(
56 int host_id,
57 int spawning_host_id) {
58 AppCacheHost* host = GetHost(host_id);
59 if (!host)
60 return false;
61 host->SetSpawningHostId(process_id_, spawning_host_id);
62 return true;
65 bool AppCacheBackendImpl::SelectCache(
66 int host_id,
67 const GURL& document_url,
68 const int64 cache_document_was_loaded_from,
69 const GURL& manifest_url) {
70 AppCacheHost* host = GetHost(host_id);
71 if (!host)
72 return false;
74 host->SelectCache(document_url, cache_document_was_loaded_from,
75 manifest_url);
76 return true;
79 bool AppCacheBackendImpl::SelectCacheForWorker(
80 int host_id, int parent_process_id, int parent_host_id) {
81 AppCacheHost* host = GetHost(host_id);
82 if (!host)
83 return false;
85 host->SelectCacheForWorker(parent_process_id, parent_host_id);
86 return true;
89 bool AppCacheBackendImpl::SelectCacheForSharedWorker(
90 int host_id, int64 appcache_id) {
91 AppCacheHost* host = GetHost(host_id);
92 if (!host)
93 return false;
95 host->SelectCacheForSharedWorker(appcache_id);
96 return true;
99 bool AppCacheBackendImpl::MarkAsForeignEntry(
100 int host_id,
101 const GURL& document_url,
102 int64 cache_document_was_loaded_from) {
103 AppCacheHost* host = GetHost(host_id);
104 if (!host)
105 return false;
107 host->MarkAsForeignEntry(document_url, cache_document_was_loaded_from);
108 return true;
111 bool AppCacheBackendImpl::GetStatusWithCallback(
112 int host_id, const GetStatusCallback& callback, void* callback_param) {
113 AppCacheHost* host = GetHost(host_id);
114 if (!host)
115 return false;
117 host->GetStatusWithCallback(callback, callback_param);
118 return true;
121 bool AppCacheBackendImpl::StartUpdateWithCallback(
122 int host_id, const StartUpdateCallback& callback, void* callback_param) {
123 AppCacheHost* host = GetHost(host_id);
124 if (!host)
125 return false;
127 host->StartUpdateWithCallback(callback, callback_param);
128 return true;
131 bool AppCacheBackendImpl::SwapCacheWithCallback(
132 int host_id, const SwapCacheCallback& callback, void* callback_param) {
133 AppCacheHost* host = GetHost(host_id);
134 if (!host)
135 return false;
137 host->SwapCacheWithCallback(callback, callback_param);
138 return true;
141 void AppCacheBackendImpl::GetResourceList(
142 int host_id, std::vector<appcache::AppCacheResourceInfo>* resource_infos) {
143 AppCacheHost* host = GetHost(host_id);
144 if (!host)
145 return;
147 host->GetResourceList(resource_infos);
150 } // namespace appcache