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

Side by Side Diff: webkit/appcache/appcache_url_request_job.cc

Issue 8399019: base::Bind usage (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « webkit/appcache/appcache_url_request_job.h ('k') | webkit/appcache/mock_appcache_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <vector> 5 #include <vector>
6 6
7 #include "webkit/appcache/appcache_url_request_job.h" 7 #include "webkit/appcache/appcache_url_request_job.h"
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 12 matching lines...) Expand all
23 23
24 AppCacheURLRequestJob::AppCacheURLRequestJob( 24 AppCacheURLRequestJob::AppCacheURLRequestJob(
25 net::URLRequest* request, AppCacheStorage* storage) 25 net::URLRequest* request, AppCacheStorage* storage)
26 : net::URLRequestJob(request), storage_(storage), 26 : net::URLRequestJob(request), storage_(storage),
27 has_been_started_(false), has_been_killed_(false), 27 has_been_started_(false), has_been_killed_(false),
28 delivery_type_(AWAITING_DELIVERY_ORDERS), 28 delivery_type_(AWAITING_DELIVERY_ORDERS),
29 group_id_(0), cache_id_(kNoCacheId), is_fallback_(false), 29 group_id_(0), cache_id_(kNoCacheId), is_fallback_(false),
30 cache_entry_not_found_(false), 30 cache_entry_not_found_(false),
31 ALLOW_THIS_IN_INITIALIZER_LIST(read_callback_( 31 ALLOW_THIS_IN_INITIALIZER_LIST(read_callback_(
32 this, &AppCacheURLRequestJob::OnReadComplete)), 32 this, &AppCacheURLRequestJob::OnReadComplete)),
33 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { 33 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
34 DCHECK(storage_); 34 DCHECK(storage_);
35 } 35 }
36 36
37 AppCacheURLRequestJob::~AppCacheURLRequestJob() { 37 AppCacheURLRequestJob::~AppCacheURLRequestJob() {
38 if (storage_) 38 if (storage_)
39 storage_->CancelDelegateCallbacks(this); 39 storage_->CancelDelegateCallbacks(this);
40 } 40 }
41 41
42 void AppCacheURLRequestJob::DeliverAppCachedResponse( 42 void AppCacheURLRequestJob::DeliverAppCachedResponse(
43 const GURL& manifest_url, int64 group_id, int64 cache_id, 43 const GURL& manifest_url, int64 group_id, int64 cache_id,
(...skipping 22 matching lines...) Expand all
66 storage_ = NULL; // not needed 66 storage_ = NULL; // not needed
67 MaybeBeginDelivery(); 67 MaybeBeginDelivery();
68 } 68 }
69 69
70 void AppCacheURLRequestJob::MaybeBeginDelivery() { 70 void AppCacheURLRequestJob::MaybeBeginDelivery() {
71 if (has_been_started() && has_delivery_orders()) { 71 if (has_been_started() && has_delivery_orders()) {
72 // Start asynchronously so that all error reporting and data 72 // Start asynchronously so that all error reporting and data
73 // callbacks happen as they would for network requests. 73 // callbacks happen as they would for network requests.
74 MessageLoop::current()->PostTask( 74 MessageLoop::current()->PostTask(
75 FROM_HERE, 75 FROM_HERE,
76 method_factory_.NewRunnableMethod( 76 base::Bind(&AppCacheURLRequestJob::BeginDelivery,
77 &AppCacheURLRequestJob::BeginDelivery)); 77 weak_factory_.GetWeakPtr()));
78 } 78 }
79 } 79 }
80 80
81 void AppCacheURLRequestJob::BeginDelivery() { 81 void AppCacheURLRequestJob::BeginDelivery() {
82 DCHECK(has_delivery_orders() && has_been_started()); 82 DCHECK(has_delivery_orders() && has_been_started());
83 83
84 if (has_been_killed()) 84 if (has_been_killed())
85 return; 85 return;
86 86
87 switch (delivery_type_) { 87 switch (delivery_type_) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 213
214 void AppCacheURLRequestJob::Kill() { 214 void AppCacheURLRequestJob::Kill() {
215 if (!has_been_killed_) { 215 if (!has_been_killed_) {
216 has_been_killed_ = true; 216 has_been_killed_ = true;
217 reader_.reset(); 217 reader_.reset();
218 if (storage_) { 218 if (storage_) {
219 storage_->CancelDelegateCallbacks(this); 219 storage_->CancelDelegateCallbacks(this);
220 storage_ = NULL; 220 storage_ = NULL;
221 } 221 }
222 net::URLRequestJob::Kill(); 222 net::URLRequestJob::Kill();
223 method_factory_.RevokeAll(); 223 weak_factory_.InvalidateWeakPtrs();
224 } 224 }
225 } 225 }
226 226
227 net::LoadState AppCacheURLRequestJob::GetLoadState() const { 227 net::LoadState AppCacheURLRequestJob::GetLoadState() const {
228 if (!has_been_started()) 228 if (!has_been_started())
229 return net::LOAD_STATE_IDLE; 229 return net::LOAD_STATE_IDLE;
230 if (!has_delivery_orders()) 230 if (!has_delivery_orders())
231 return net::LOAD_STATE_WAITING_FOR_CACHE; 231 return net::LOAD_STATE_WAITING_FOR_CACHE;
232 if (delivery_type_ != APPCACHED_DELIVERY) 232 if (delivery_type_ != APPCACHED_DELIVERY)
233 return net::LOAD_STATE_IDLE; 233 return net::LOAD_STATE_IDLE;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 return; 282 return;
283 } 283 }
284 284
285 // If multiple ranges are requested, we play dumb and 285 // If multiple ranges are requested, we play dumb and
286 // return the entire response with 200 OK. 286 // return the entire response with 200 OK.
287 if (ranges.size() == 1U) 287 if (ranges.size() == 1U)
288 range_requested_ = ranges[0]; 288 range_requested_ = ranges[0];
289 } 289 }
290 290
291 } // namespace appcache 291 } // namespace appcache
OLDNEW
« no previous file with comments | « webkit/appcache/appcache_url_request_job.h ('k') | webkit/appcache/mock_appcache_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698