OLD | NEW |
---|---|
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/loader/async_resource_handler.h" | 5 #include "content/browser/loader/async_resource_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 net::URLRequest* request, | 80 net::URLRequest* request, |
81 ResourceDispatcherHostImpl* rdh) | 81 ResourceDispatcherHostImpl* rdh) |
82 : ResourceMessageDelegate(request), | 82 : ResourceMessageDelegate(request), |
83 request_(request), | 83 request_(request), |
84 rdh_(rdh), | 84 rdh_(rdh), |
85 pending_data_count_(0), | 85 pending_data_count_(0), |
86 allocation_size_(0), | 86 allocation_size_(0), |
87 did_defer_(false), | 87 did_defer_(false), |
88 has_checked_for_sufficient_resources_(false), | 88 has_checked_for_sufficient_resources_(false), |
89 sent_received_response_msg_(false), | 89 sent_received_response_msg_(false), |
90 sent_first_data_msg_(false) { | 90 sent_first_data_msg_(false), |
91 detached_reads_(false) { | |
91 InitializeResourceBufferConstants(); | 92 InitializeResourceBufferConstants(); |
92 } | 93 } |
93 | 94 |
94 AsyncResourceHandler::~AsyncResourceHandler() { | 95 AsyncResourceHandler::~AsyncResourceHandler() { |
95 if (has_checked_for_sufficient_resources_) | 96 if (has_checked_for_sufficient_resources_) |
96 rdh_->FinishedWithResourcesForRequest(request_); | 97 rdh_->FinishedWithResourcesForRequest(request_); |
97 } | 98 } |
98 | 99 |
99 bool AsyncResourceHandler::OnMessageReceived(const IPC::Message& message, | 100 bool AsyncResourceHandler::OnMessageReceived(const IPC::Message& message, |
100 bool* message_was_ok) { | 101 bool* message_was_ok) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
240 "Net.AsyncResourceHandler_SharedIOBuffer_Alloc", | 241 "Net.AsyncResourceHandler_SharedIOBuffer_Alloc", |
241 *buf_size, 0, kMaxAllocationSize, 100); | 242 *buf_size, 0, kMaxAllocationSize, 100); |
242 return true; | 243 return true; |
243 } | 244 } |
244 | 245 |
245 bool AsyncResourceHandler::OnReadCompleted(int request_id, int bytes_read, | 246 bool AsyncResourceHandler::OnReadCompleted(int request_id, int bytes_read, |
246 bool* defer) { | 247 bool* defer) { |
247 if (!bytes_read) | 248 if (!bytes_read) |
248 return true; | 249 return true; |
249 | 250 |
251 if (detached_reads_) { | |
252 buffer_->RecycleLeastRecentlyAllocated(); | |
253 return true; | |
254 } | |
255 | |
250 const ResourceRequestInfoImpl* info = | 256 const ResourceRequestInfoImpl* info = |
251 ResourceRequestInfoImpl::ForRequest(request_); | 257 ResourceRequestInfoImpl::ForRequest(request_); |
252 if (!info->filter()) | 258 if (!info->filter()) |
253 return false; | 259 return false; |
254 | 260 |
255 buffer_->ShrinkLastAllocation(bytes_read); | 261 buffer_->ShrinkLastAllocation(bytes_read); |
256 | 262 |
257 UMA_HISTOGRAM_CUSTOM_COUNTS( | 263 UMA_HISTOGRAM_CUSTOM_COUNTS( |
258 "Net.AsyncResourceHandler_SharedIOBuffer_Used", | 264 "Net.AsyncResourceHandler_SharedIOBuffer_Used", |
259 bytes_read, 0, kMaxAllocationSize, 100); | 265 bytes_read, 0, kMaxAllocationSize, 100); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
377 kMaxAllocationSize); | 383 kMaxAllocationSize); |
378 } | 384 } |
379 | 385 |
380 void AsyncResourceHandler::ResumeIfDeferred() { | 386 void AsyncResourceHandler::ResumeIfDeferred() { |
381 if (did_defer_) { | 387 if (did_defer_) { |
382 did_defer_ = false; | 388 did_defer_ = false; |
383 controller()->Resume(); | 389 controller()->Resume(); |
384 } | 390 } |
385 } | 391 } |
386 | 392 |
393 void AsyncResourceHandler::SetDetachedReads(bool detached_reads) { | |
394 // We don't support moving from detached to not detached | |
395 CHECK(!(detached_reads_ && detached_reads)); | |
mmenke
2013/10/07 19:16:24
Unless there's some reason to be particularly conc
jkarlin2
2013/10/08 11:53:01
Done.
| |
396 detached_reads_ = detached_reads; | |
397 } | |
398 | |
387 } // namespace content | 399 } // namespace content |
OLD | NEW |