Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "content/browser/appcache/appcache_backend_impl.h" | 5 #include "content/browser/appcache/appcache_backend_impl.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "content/browser/appcache/appcache.h" | 8 #include "content/browser/appcache/appcache.h" |
| 9 #include "content/browser/appcache/appcache_group.h" | 9 #include "content/browser/appcache/appcache_group.h" |
| 10 #include "content/browser/appcache/appcache_service_impl.h" | 10 #include "content/browser/appcache/appcache_service_impl.h" |
| 11 #include "content/public/common/browser_side_navigation_policy.h" | |
| 11 | 12 |
| 12 namespace content { | 13 namespace content { |
| 13 | 14 |
| 14 AppCacheBackendImpl::AppCacheBackendImpl() | 15 AppCacheBackendImpl::AppCacheBackendImpl() |
| 15 : service_(NULL), | 16 : service_(NULL), frontend_(NULL), process_id_(0), frame_id_(-1) {} |
| 16 frontend_(NULL), | |
| 17 process_id_(0) { | |
| 18 } | |
| 19 | 17 |
| 20 AppCacheBackendImpl::~AppCacheBackendImpl() { | 18 AppCacheBackendImpl::~AppCacheBackendImpl() { |
| 21 hosts_.clear(); | 19 hosts_.clear(); |
| 22 if (service_) | 20 if (service_) { |
| 23 service_->UnregisterBackend(this); | 21 if (process_id_ != -1) { |
|
michaeln
2016/11/22 00:17:27
are there constants defined for these -1 values an
ananta
2016/11/23 04:05:14
Reverted
| |
| 22 service_->UnregisterBackend(this); | |
| 23 } else { | |
| 24 DCHECK(frame_id_ != -1); | |
| 25 service_->UnregisterBackendForFrame(this); | |
| 26 } | |
| 27 } | |
| 24 } | 28 } |
| 25 | 29 |
| 26 void AppCacheBackendImpl::Initialize(AppCacheServiceImpl* service, | 30 void AppCacheBackendImpl::Initialize(AppCacheServiceImpl* service, |
| 27 AppCacheFrontend* frontend, | 31 AppCacheFrontend* frontend, |
| 28 int process_id) { | 32 int process_id, |
| 33 int frame_id) { | |
| 29 DCHECK(!service_ && !frontend_ && frontend && service); | 34 DCHECK(!service_ && !frontend_ && frontend && service); |
| 30 service_ = service; | 35 service_ = service; |
| 31 frontend_ = frontend; | 36 frontend_ = frontend; |
| 32 process_id_ = process_id; | 37 process_id_ = process_id; |
| 33 service_->RegisterBackend(this); | 38 frame_id_ = frame_id; |
| 39 if (frame_id != -1) { | |
|
michaeln
2016/11/22 00:17:27
are frame_id and process_id mutually exclusive
ananta
2016/11/23 04:05:14
Reverted
| |
| 40 DCHECK(IsBrowserSideNavigationEnabled()); | |
| 41 service_->RegisterBackendForFrame(this); | |
| 42 } else { | |
| 43 service_->RegisterBackend(this); | |
| 44 } | |
| 34 } | 45 } |
| 35 | 46 |
| 36 bool AppCacheBackendImpl::RegisterHost(int id) { | 47 bool AppCacheBackendImpl::RegisterHost(int id) { |
| 37 if (GetHost(id)) | 48 if (GetHost(id)) |
| 38 return false; | 49 return false; |
| 39 | 50 |
| 40 hosts_[id] = base::MakeUnique<AppCacheHost>(id, frontend_, service_); | 51 hosts_[id] = base::MakeUnique<AppCacheHost>(id, frontend_, service_); |
| 41 return true; | 52 return true; |
| 42 } | 53 } |
| 43 | 54 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 auto found = hosts_.find(new_host_id); | 170 auto found = hosts_.find(new_host_id); |
| 160 if (found == hosts_.end()) { | 171 if (found == hosts_.end()) { |
| 161 NOTREACHED(); | 172 NOTREACHED(); |
| 162 return; | 173 return; |
| 163 } | 174 } |
| 164 | 175 |
| 165 host->CompleteTransfer(new_host_id, frontend_); | 176 host->CompleteTransfer(new_host_id, frontend_); |
| 166 found->second = std::move(host); | 177 found->second = std::move(host); |
| 167 } | 178 } |
| 168 | 179 |
| 180 void AppCacheBackendImpl::FrameNavigationCommitted( | |
| 181 AppCacheFrontend* frontend, | |
| 182 AppCacheServiceImpl* service) { | |
| 183 DCHECK(frontend); | |
| 184 DCHECK(service); | |
| 185 DCHECK(IsBrowserSideNavigationEnabled()); | |
| 186 | |
| 187 frontend_ = frontend; | |
| 188 service_ = service; | |
| 189 | |
| 190 HostMap::iterator host_index; | |
| 191 for (host_index = hosts_.begin(); host_index != hosts_.end(); ++host_index) | |
|
michaeln
2016/11/22 00:17:27
for (auto& iter : backend->hosts_)
ananta
2016/11/23 04:05:14
Reverted
| |
| 192 host_index->second->FrameNavigationCommitted(frontend, service); | |
| 193 } | |
| 194 | |
| 195 void AppCacheBackendImpl::CopyExistingHosts(AppCacheBackendImpl* backend) { | |
| 196 DCHECK(IsBrowserSideNavigationEnabled()); | |
| 197 | |
| 198 HostMap::iterator host_index; | |
| 199 for (host_index = backend->hosts_.begin(); | |
|
michaeln
2016/11/22 00:17:27
iter might be a better name, i got tripped seeing
ananta
2016/11/23 04:05:14
Reverted
| |
| 200 host_index != backend->hosts_.end(); ++host_index) { | |
| 201 DCHECK(hosts_.find(host_index->first) == hosts_.end()); | |
| 202 hosts_[host_index->first] = std::move(host_index->second); | |
| 203 } | |
| 204 } | |
| 205 | |
| 169 } // namespace content | 206 } // namespace content |
| OLD | NEW |