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

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

Issue 1549113002: Switch to standard integer types in content/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 12 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_url_request_job.h" 5 #include "content/browser/appcache/appcache_url_request_job.h"
6 6
7 #include <vector> 7 #include <vector>
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 on_prepare_to_restart_callback_(restart_callback), 49 on_prepare_to_restart_callback_(restart_callback),
50 weak_factory_(this) { 50 weak_factory_(this) {
51 DCHECK(storage_); 51 DCHECK(storage_);
52 } 52 }
53 53
54 AppCacheURLRequestJob::~AppCacheURLRequestJob() { 54 AppCacheURLRequestJob::~AppCacheURLRequestJob() {
55 if (storage_) 55 if (storage_)
56 storage_->CancelDelegateCallbacks(this); 56 storage_->CancelDelegateCallbacks(this);
57 } 57 }
58 58
59 void AppCacheURLRequestJob::DeliverAppCachedResponse( 59 void AppCacheURLRequestJob::DeliverAppCachedResponse(const GURL& manifest_url,
60 const GURL& manifest_url, int64 group_id, int64 cache_id, 60 int64_t group_id,
61 const AppCacheEntry& entry, bool is_fallback) { 61 int64_t cache_id,
62 const AppCacheEntry& entry,
63 bool is_fallback) {
62 DCHECK(!has_delivery_orders()); 64 DCHECK(!has_delivery_orders());
63 DCHECK(entry.has_response_id()); 65 DCHECK(entry.has_response_id());
64 delivery_type_ = APPCACHED_DELIVERY; 66 delivery_type_ = APPCACHED_DELIVERY;
65 manifest_url_ = manifest_url; 67 manifest_url_ = manifest_url;
66 group_id_ = group_id; 68 group_id_ = group_id;
67 cache_id_ = cache_id; 69 cache_id_ = cache_id;
68 entry_ = entry; 70 entry_ = entry;
69 is_fallback_ = is_fallback; 71 is_fallback_ = is_fallback;
70 MaybeBeginDelivery(); 72 MaybeBeginDelivery();
71 } 73 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 // provides a response. The sequence goes like this... 162 // provides a response. The sequence goes like this...
161 // 163 //
162 // 1. First we load the cache. 164 // 1. First we load the cache.
163 // 2. Then if the handler is not spun up, we load the script resource which 165 // 2. Then if the handler is not spun up, we load the script resource which
164 // is needed to spin it up. 166 // is needed to spin it up.
165 // 3. Then we ask then we ask the handler to compute a response. 167 // 3. Then we ask then we ask the handler to compute a response.
166 // 4. Finally we deilver that response to the caller. 168 // 4. Finally we deilver that response to the caller.
167 storage_->LoadCache(cache_id_, this); 169 storage_->LoadCache(cache_id_, this);
168 } 170 }
169 171
170 void AppCacheURLRequestJob::OnCacheLoaded(AppCache* cache, int64 cache_id) { 172 void AppCacheURLRequestJob::OnCacheLoaded(AppCache* cache, int64_t cache_id) {
171 DCHECK_EQ(cache_id_, cache_id); 173 DCHECK_EQ(cache_id_, cache_id);
172 DCHECK(!has_been_killed()); 174 DCHECK(!has_been_killed());
173 175
174 if (!cache) { 176 if (!cache) {
175 BeginErrorDelivery("cache load failed"); 177 BeginErrorDelivery("cache load failed");
176 return; 178 return;
177 } 179 }
178 180
179 // Keep references to ensure they don't go out of scope until job completion. 181 // Keep references to ensure they don't go out of scope until job completion.
180 cache_ = cache; 182 cache_ = cache;
181 group_ = cache->owning_group(); 183 group_ = cache->owning_group();
182 184
183 // If the handler is spun up, ask it to compute a response. 185 // If the handler is spun up, ask it to compute a response.
184 AppCacheExecutableHandler* handler = 186 AppCacheExecutableHandler* handler =
185 cache->GetExecutableHandler(entry_.response_id()); 187 cache->GetExecutableHandler(entry_.response_id());
186 if (handler) { 188 if (handler) {
187 InvokeExecutableHandler(handler); 189 InvokeExecutableHandler(handler);
188 return; 190 return;
189 } 191 }
190 192
191 // Handler is not spun up yet, load the script resource to do that. 193 // Handler is not spun up yet, load the script resource to do that.
192 // NOTE: This is not ideal since multiple jobs may be doing this, 194 // NOTE: This is not ideal since multiple jobs may be doing this,
193 // concurrently but close enough for now, the first to load the script 195 // concurrently but close enough for now, the first to load the script
194 // will win. 196 // will win.
195 197
196 // Read the script data, truncating if its too large. 198 // Read the script data, truncating if its too large.
197 // NOTE: we just issue one read and don't bother chaining if the resource 199 // NOTE: we just issue one read and don't bother chaining if the resource
198 // is very (very) large, close enough for now. 200 // is very (very) large, close enough for now.
199 const int64 kLimit = 500 * 1000; 201 const int64_t kLimit = 500 * 1000;
200 handler_source_buffer_ = new net::GrowableIOBuffer(); 202 handler_source_buffer_ = new net::GrowableIOBuffer();
201 handler_source_buffer_->SetCapacity(kLimit); 203 handler_source_buffer_->SetCapacity(kLimit);
202 handler_source_reader_.reset(storage_->CreateResponseReader( 204 handler_source_reader_.reset(storage_->CreateResponseReader(
203 manifest_url_, group_id_, entry_.response_id())); 205 manifest_url_, group_id_, entry_.response_id()));
204 handler_source_reader_->ReadData( 206 handler_source_reader_->ReadData(
205 handler_source_buffer_.get(), 207 handler_source_buffer_.get(),
206 kLimit, 208 kLimit,
207 base::Bind(&AppCacheURLRequestJob::OnExecutableSourceLoaded, 209 base::Bind(&AppCacheURLRequestJob::OnExecutableSourceLoaded,
208 base::Unretained(this))); 210 base::Unretained(this)));
209 } 211 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 void AppCacheURLRequestJob::BeginErrorDelivery(const char* message) { 271 void AppCacheURLRequestJob::BeginErrorDelivery(const char* message) {
270 if (host_) 272 if (host_)
271 host_->frontend()->OnLogMessage(host_->host_id(), APPCACHE_LOG_ERROR, 273 host_->frontend()->OnLogMessage(host_->host_id(), APPCACHE_LOG_ERROR,
272 message); 274 message);
273 delivery_type_ = ERROR_DELIVERY; 275 delivery_type_ = ERROR_DELIVERY;
274 storage_ = NULL; 276 storage_ = NULL;
275 BeginDelivery(); 277 BeginDelivery();
276 } 278 }
277 279
278 void AppCacheURLRequestJob::OnResponseInfoLoaded( 280 void AppCacheURLRequestJob::OnResponseInfoLoaded(
279 AppCacheResponseInfo* response_info, int64 response_id) { 281 AppCacheResponseInfo* response_info,
282 int64_t response_id) {
280 DCHECK(is_delivering_appcache_response()); 283 DCHECK(is_delivering_appcache_response());
281 if (response_info) { 284 if (response_info) {
282 info_ = response_info; 285 info_ = response_info;
283 reader_.reset(storage_->CreateResponseReader( 286 reader_.reset(storage_->CreateResponseReader(
284 manifest_url_, group_id_, entry_.response_id())); 287 manifest_url_, group_id_, entry_.response_id()));
285 288
286 if (is_range_request()) 289 if (is_range_request())
287 SetupRangeResponse(); 290 SetupRangeResponse();
288 291
289 NotifyHeadersComplete(); 292 NotifyHeadersComplete();
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 if (ranges.size() == 1U) 447 if (ranges.size() == 1U)
445 range_requested_ = ranges[0]; 448 range_requested_ = ranges[0];
446 } 449 }
447 450
448 void AppCacheURLRequestJob::NotifyRestartRequired() { 451 void AppCacheURLRequestJob::NotifyRestartRequired() {
449 on_prepare_to_restart_callback_.Run(); 452 on_prepare_to_restart_callback_.Run();
450 URLRequestJob::NotifyRestartRequired(); 453 URLRequestJob::NotifyRestartRequired();
451 } 454 }
452 455
453 } // namespace content 456 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_url_request_job.h ('k') | content/browser/appcache/appcache_url_request_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698