Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: content/browser/appcache/appcache_service_impl.cc

Issue 667943003: Standardize usage of virtual/override/final in content/browser/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_service_impl.h" 5 #include "content/browser/appcache/appcache_service_impl.h"
6 6
7 #include <functional> 7 #include <functional>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 class AppCacheServiceImpl::AsyncHelper 45 class AppCacheServiceImpl::AsyncHelper
46 : public AppCacheStorage::Delegate { 46 : public AppCacheStorage::Delegate {
47 public: 47 public:
48 AsyncHelper(AppCacheServiceImpl* service, 48 AsyncHelper(AppCacheServiceImpl* service,
49 const net::CompletionCallback& callback) 49 const net::CompletionCallback& callback)
50 : service_(service), callback_(callback) { 50 : service_(service), callback_(callback) {
51 service_->pending_helpers_.insert(this); 51 service_->pending_helpers_.insert(this);
52 } 52 }
53 53
54 virtual ~AsyncHelper() { 54 ~AsyncHelper() override {
55 if (service_) 55 if (service_)
56 service_->pending_helpers_.erase(this); 56 service_->pending_helpers_.erase(this);
57 } 57 }
58 58
59 virtual void Start() = 0; 59 virtual void Start() = 0;
60 virtual void Cancel(); 60 virtual void Cancel();
61 61
62 protected: 62 protected:
63 void CallCallback(int rv) { 63 void CallCallback(int rv) {
64 if (!callback_.is_null()) { 64 if (!callback_.is_null()) {
(...skipping 22 matching lines...) Expand all
87 class AppCacheServiceImpl::CanHandleOfflineHelper : AsyncHelper { 87 class AppCacheServiceImpl::CanHandleOfflineHelper : AsyncHelper {
88 public: 88 public:
89 CanHandleOfflineHelper( 89 CanHandleOfflineHelper(
90 AppCacheServiceImpl* service, const GURL& url, 90 AppCacheServiceImpl* service, const GURL& url,
91 const GURL& first_party, const net::CompletionCallback& callback) 91 const GURL& first_party, const net::CompletionCallback& callback)
92 : AsyncHelper(service, callback), 92 : AsyncHelper(service, callback),
93 url_(url), 93 url_(url),
94 first_party_(first_party) { 94 first_party_(first_party) {
95 } 95 }
96 96
97 virtual void Start() override { 97 void Start() override {
98 AppCachePolicy* policy = service_->appcache_policy(); 98 AppCachePolicy* policy = service_->appcache_policy();
99 if (policy && !policy->CanLoadAppCache(url_, first_party_)) { 99 if (policy && !policy->CanLoadAppCache(url_, first_party_)) {
100 CallCallback(net::ERR_FAILED); 100 CallCallback(net::ERR_FAILED);
101 delete this; 101 delete this;
102 return; 102 return;
103 } 103 }
104 104
105 service_->storage()->FindResponseForMainRequest(url_, GURL(), this); 105 service_->storage()->FindResponseForMainRequest(url_, GURL(), this);
106 } 106 }
107 107
108 private: 108 private:
109 // AppCacheStorage::Delegate implementation. 109 // AppCacheStorage::Delegate implementation.
110 virtual void OnMainResponseFound( 110 void OnMainResponseFound(const GURL& url,
111 const GURL& url, const AppCacheEntry& entry, 111 const AppCacheEntry& entry,
112 const GURL& fallback_url, const AppCacheEntry& fallback_entry, 112 const GURL& fallback_url,
113 int64 cache_id, int64 group_id, const GURL& mainfest_url) override; 113 const AppCacheEntry& fallback_entry,
114 int64 cache_id,
115 int64 group_id,
116 const GURL& mainfest_url) override;
114 117
115 GURL url_; 118 GURL url_;
116 GURL first_party_; 119 GURL first_party_;
117 120
118 DISALLOW_COPY_AND_ASSIGN(CanHandleOfflineHelper); 121 DISALLOW_COPY_AND_ASSIGN(CanHandleOfflineHelper);
119 }; 122 };
120 123
121 void AppCacheServiceImpl::CanHandleOfflineHelper::OnMainResponseFound( 124 void AppCacheServiceImpl::CanHandleOfflineHelper::OnMainResponseFound(
122 const GURL& url, const AppCacheEntry& entry, 125 const GURL& url, const AppCacheEntry& entry,
123 const GURL& fallback_url, const AppCacheEntry& fallback_entry, 126 const GURL& fallback_url, const AppCacheEntry& fallback_entry,
124 int64 cache_id, int64 group_id, const GURL& manifest_url) { 127 int64 cache_id, int64 group_id, const GURL& manifest_url) {
125 bool can = (entry.has_response_id() || fallback_entry.has_response_id()); 128 bool can = (entry.has_response_id() || fallback_entry.has_response_id());
126 CallCallback(can ? net::OK : net::ERR_FAILED); 129 CallCallback(can ? net::OK : net::ERR_FAILED);
127 delete this; 130 delete this;
128 } 131 }
129 132
130 // DeleteHelper ------- 133 // DeleteHelper -------
131 134
132 class AppCacheServiceImpl::DeleteHelper : public AsyncHelper { 135 class AppCacheServiceImpl::DeleteHelper : public AsyncHelper {
133 public: 136 public:
134 DeleteHelper( 137 DeleteHelper(
135 AppCacheServiceImpl* service, const GURL& manifest_url, 138 AppCacheServiceImpl* service, const GURL& manifest_url,
136 const net::CompletionCallback& callback) 139 const net::CompletionCallback& callback)
137 : AsyncHelper(service, callback), manifest_url_(manifest_url) { 140 : AsyncHelper(service, callback), manifest_url_(manifest_url) {
138 } 141 }
139 142
140 virtual void Start() override { 143 void Start() override {
141 service_->storage()->LoadOrCreateGroup(manifest_url_, this); 144 service_->storage()->LoadOrCreateGroup(manifest_url_, this);
142 } 145 }
143 146
144 private: 147 private:
145 // AppCacheStorage::Delegate implementation. 148 // AppCacheStorage::Delegate implementation.
146 virtual void OnGroupLoaded( 149 void OnGroupLoaded(AppCacheGroup* group, const GURL& manifest_url) override;
147 AppCacheGroup* group, const GURL& manifest_url) override; 150 void OnGroupMadeObsolete(AppCacheGroup* group,
148 virtual void OnGroupMadeObsolete(AppCacheGroup* group, 151 bool success,
149 bool success, 152 int response_code) override;
150 int response_code) override;
151 153
152 GURL manifest_url_; 154 GURL manifest_url_;
153 DISALLOW_COPY_AND_ASSIGN(DeleteHelper); 155 DISALLOW_COPY_AND_ASSIGN(DeleteHelper);
154 }; 156 };
155 157
156 void AppCacheServiceImpl::DeleteHelper::OnGroupLoaded( 158 void AppCacheServiceImpl::DeleteHelper::OnGroupLoaded(
157 AppCacheGroup* group, const GURL& manifest_url) { 159 AppCacheGroup* group, const GURL& manifest_url) {
158 if (group) { 160 if (group) {
159 group->set_being_deleted(true); 161 group->set_being_deleted(true);
160 group->CancelUpdate(); 162 group->CancelUpdate();
(...skipping 16 matching lines...) Expand all
177 179
178 class AppCacheServiceImpl::DeleteOriginHelper : public AsyncHelper { 180 class AppCacheServiceImpl::DeleteOriginHelper : public AsyncHelper {
179 public: 181 public:
180 DeleteOriginHelper( 182 DeleteOriginHelper(
181 AppCacheServiceImpl* service, const GURL& origin, 183 AppCacheServiceImpl* service, const GURL& origin,
182 const net::CompletionCallback& callback) 184 const net::CompletionCallback& callback)
183 : AsyncHelper(service, callback), origin_(origin), 185 : AsyncHelper(service, callback), origin_(origin),
184 num_caches_to_delete_(0), successes_(0), failures_(0) { 186 num_caches_to_delete_(0), successes_(0), failures_(0) {
185 } 187 }
186 188
187 virtual void Start() override { 189 void Start() override {
188 // We start by listing all caches, continues in OnAllInfo(). 190 // We start by listing all caches, continues in OnAllInfo().
189 service_->storage()->GetAllInfo(this); 191 service_->storage()->GetAllInfo(this);
190 } 192 }
191 193
192 private: 194 private:
193 // AppCacheStorage::Delegate implementation. 195 // AppCacheStorage::Delegate implementation.
194 virtual void OnAllInfo(AppCacheInfoCollection* collection) override; 196 void OnAllInfo(AppCacheInfoCollection* collection) override;
195 virtual void OnGroupLoaded( 197 void OnGroupLoaded(AppCacheGroup* group, const GURL& manifest_url) override;
196 AppCacheGroup* group, const GURL& manifest_url) override; 198 void OnGroupMadeObsolete(AppCacheGroup* group,
197 virtual void OnGroupMadeObsolete(AppCacheGroup* group, 199 bool success,
198 bool success, 200 int response_code) override;
199 int response_code) override;
200 201
201 void CacheCompleted(bool success); 202 void CacheCompleted(bool success);
202 203
203 GURL origin_; 204 GURL origin_;
204 int num_caches_to_delete_; 205 int num_caches_to_delete_;
205 int successes_; 206 int successes_;
206 int failures_; 207 int failures_;
207 208
208 DISALLOW_COPY_AND_ASSIGN(DeleteOriginHelper); 209 DISALLOW_COPY_AND_ASSIGN(DeleteOriginHelper);
209 }; 210 };
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 // GetInfoHelper ------- 272 // GetInfoHelper -------
272 273
273 class AppCacheServiceImpl::GetInfoHelper : AsyncHelper { 274 class AppCacheServiceImpl::GetInfoHelper : AsyncHelper {
274 public: 275 public:
275 GetInfoHelper( 276 GetInfoHelper(
276 AppCacheServiceImpl* service, AppCacheInfoCollection* collection, 277 AppCacheServiceImpl* service, AppCacheInfoCollection* collection,
277 const net::CompletionCallback& callback) 278 const net::CompletionCallback& callback)
278 : AsyncHelper(service, callback), collection_(collection) { 279 : AsyncHelper(service, callback), collection_(collection) {
279 } 280 }
280 281
281 virtual void Start() override { 282 void Start() override { service_->storage()->GetAllInfo(this); }
282 service_->storage()->GetAllInfo(this);
283 }
284 283
285 private: 284 private:
286 // AppCacheStorage::Delegate implementation. 285 // AppCacheStorage::Delegate implementation.
287 virtual void OnAllInfo(AppCacheInfoCollection* collection) override; 286 void OnAllInfo(AppCacheInfoCollection* collection) override;
288 287
289 scoped_refptr<AppCacheInfoCollection> collection_; 288 scoped_refptr<AppCacheInfoCollection> collection_;
290 289
291 DISALLOW_COPY_AND_ASSIGN(GetInfoHelper); 290 DISALLOW_COPY_AND_ASSIGN(GetInfoHelper);
292 }; 291 };
293 292
294 void AppCacheServiceImpl::GetInfoHelper::OnAllInfo( 293 void AppCacheServiceImpl::GetInfoHelper::OnAllInfo(
295 AppCacheInfoCollection* collection) { 294 AppCacheInfoCollection* collection) {
296 if (collection) 295 if (collection)
297 collection->infos_by_origin.swap(collection_->infos_by_origin); 296 collection->infos_by_origin.swap(collection_->infos_by_origin);
(...skipping 11 matching lines...) Expand all
309 : AsyncHelper(service, net::CompletionCallback()), 308 : AsyncHelper(service, net::CompletionCallback()),
310 manifest_url_(manifest_url), 309 manifest_url_(manifest_url),
311 cache_id_(cache_id), 310 cache_id_(cache_id),
312 response_id_(response_id), 311 response_id_(response_id),
313 kIOBufferSize(32 * 1024), 312 kIOBufferSize(32 * 1024),
314 expected_total_size_(0), 313 expected_total_size_(0),
315 amount_headers_read_(0), 314 amount_headers_read_(0),
316 amount_data_read_(0) { 315 amount_data_read_(0) {
317 } 316 }
318 317
319 virtual void Start() override { 318 void Start() override {
320 service_->storage()->LoadOrCreateGroup(manifest_url_, this); 319 service_->storage()->LoadOrCreateGroup(manifest_url_, this);
321 } 320 }
322 321
323 virtual void Cancel() override { 322 void Cancel() override {
324 AppCacheHistograms::CountCheckResponseResult( 323 AppCacheHistograms::CountCheckResponseResult(
325 AppCacheHistograms::CHECK_CANCELED); 324 AppCacheHistograms::CHECK_CANCELED);
326 response_reader_.reset(); 325 response_reader_.reset();
327 AsyncHelper::Cancel(); 326 AsyncHelper::Cancel();
328 } 327 }
329 328
330 private: 329 private:
331 virtual void OnGroupLoaded(AppCacheGroup* group, 330 void OnGroupLoaded(AppCacheGroup* group, const GURL& manifest_url) override;
332 const GURL& manifest_url) override;
333 void OnReadInfoComplete(int result); 331 void OnReadInfoComplete(int result);
334 void OnReadDataComplete(int result); 332 void OnReadDataComplete(int result);
335 333
336 // Inputs describing what to check. 334 // Inputs describing what to check.
337 GURL manifest_url_; 335 GURL manifest_url_;
338 int64 cache_id_; 336 int64 cache_id_;
339 int64 response_id_; 337 int64 response_id_;
340 338
341 // Internals used to perform the checks. 339 // Internals used to perform the checks.
342 const int kIOBufferSize; 340 const int kIOBufferSize;
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 backends_.insert( 571 backends_.insert(
574 BackendMap::value_type(backend_impl->process_id(), backend_impl)); 572 BackendMap::value_type(backend_impl->process_id(), backend_impl));
575 } 573 }
576 574
577 void AppCacheServiceImpl::UnregisterBackend( 575 void AppCacheServiceImpl::UnregisterBackend(
578 AppCacheBackendImpl* backend_impl) { 576 AppCacheBackendImpl* backend_impl) {
579 backends_.erase(backend_impl->process_id()); 577 backends_.erase(backend_impl->process_id());
580 } 578 }
581 579
582 } // namespace content 580 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_service_impl.h ('k') | content/browser/appcache/appcache_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698