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

Side by Side Diff: net/url_request/view_cache_helper.cc

Issue 11275088: Remove implicit scoped_refptr operator T* Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 8 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
« no previous file with comments | « net/url_request/url_request_job.cc ('k') | net/websockets/websocket_job.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) 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 "net/url_request/view_cache_helper.h" 5 #include "net/url_request/view_cache_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "net/base/escape.h" 10 #include "net/base/escape.h"
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 } 280 }
281 281
282 int ViewCacheHelper::DoReadResponse() { 282 int ViewCacheHelper::DoReadResponse() {
283 next_state_ = STATE_READ_RESPONSE_COMPLETE; 283 next_state_ = STATE_READ_RESPONSE_COMPLETE;
284 buf_len_ = entry_->GetDataSize(0); 284 buf_len_ = entry_->GetDataSize(0);
285 if (!buf_len_) 285 if (!buf_len_)
286 return buf_len_; 286 return buf_len_;
287 287
288 buf_ = new IOBuffer(buf_len_); 288 buf_ = new IOBuffer(buf_len_);
289 return entry_->ReadData( 289 return entry_->ReadData(
290 0, 0, buf_, buf_len_, 290 0, 0, buf_.get(), buf_len_,
291 base::Bind(&ViewCacheHelper::OnIOComplete, weak_factory_.GetWeakPtr())); 291 base::Bind(&ViewCacheHelper::OnIOComplete, weak_factory_.GetWeakPtr()));
292 } 292 }
293 293
294 int ViewCacheHelper::DoReadResponseComplete(int result) { 294 int ViewCacheHelper::DoReadResponseComplete(int result) {
295 if (result && result == buf_len_) { 295 if (result && result == buf_len_) {
296 HttpResponseInfo response; 296 HttpResponseInfo response;
297 bool truncated; 297 bool truncated;
298 if (HttpCache::ParseResponseInfo(buf_->data(), buf_len_, &response, 298 if (HttpCache::ParseResponseInfo(buf_->data(), buf_len_, &response,
299 &truncated) && 299 &truncated) &&
300 response.headers) { 300 response.headers.get()) {
301 if (truncated) 301 if (truncated)
302 data_->append("<pre>RESPONSE_INFO_TRUNCATED</pre>"); 302 data_->append("<pre>RESPONSE_INFO_TRUNCATED</pre>");
303 303
304 data_->append("<hr><pre>"); 304 data_->append("<hr><pre>");
305 data_->append(EscapeForHTML(response.headers->GetStatusLine())); 305 data_->append(EscapeForHTML(response.headers->GetStatusLine()));
306 data_->push_back('\n'); 306 data_->push_back('\n');
307 307
308 void* iter = NULL; 308 void* iter = NULL;
309 std::string name, value; 309 std::string name, value;
310 while (response.headers->EnumerateHeaderLines(&iter, &name, &value)) { 310 while (response.headers->EnumerateHeaderLines(&iter, &name, &value)) {
(...skipping 14 matching lines...) Expand all
325 int ViewCacheHelper::DoReadData() { 325 int ViewCacheHelper::DoReadData() {
326 data_->append("<hr><pre>"); 326 data_->append("<hr><pre>");
327 327
328 next_state_ = STATE_READ_DATA_COMPLETE; 328 next_state_ = STATE_READ_DATA_COMPLETE;
329 buf_len_ = entry_->GetDataSize(index_); 329 buf_len_ = entry_->GetDataSize(index_);
330 if (!buf_len_) 330 if (!buf_len_)
331 return buf_len_; 331 return buf_len_;
332 332
333 buf_ = new IOBuffer(buf_len_); 333 buf_ = new IOBuffer(buf_len_);
334 return entry_->ReadData( 334 return entry_->ReadData(
335 index_, 0, buf_, buf_len_, 335 index_, 0, buf_.get(), buf_len_,
336 base::Bind(&ViewCacheHelper::OnIOComplete, weak_factory_.GetWeakPtr())); 336 base::Bind(&ViewCacheHelper::OnIOComplete, weak_factory_.GetWeakPtr()));
337 } 337 }
338 338
339 int ViewCacheHelper::DoReadDataComplete(int result) { 339 int ViewCacheHelper::DoReadDataComplete(int result) {
340 if (result && result == buf_len_) { 340 if (result && result == buf_len_) {
341 HexDump(buf_->data(), buf_len_, data_); 341 HexDump(buf_->data(), buf_len_, data_);
342 } 342 }
343 data_->append("</pre>"); 343 data_->append("</pre>");
344 index_++; 344 index_++;
345 if (index_ < HttpCache::kNumCacheEntryDataIndices) { 345 if (index_ < HttpCache::kNumCacheEntryDataIndices) {
346 next_state_ = STATE_READ_DATA; 346 next_state_ = STATE_READ_DATA;
347 } else { 347 } else {
348 data_->append(VIEW_CACHE_TAIL); 348 data_->append(VIEW_CACHE_TAIL);
349 entry_->Close(); 349 entry_->Close();
350 entry_ = NULL; 350 entry_ = NULL;
351 } 351 }
352 return OK; 352 return OK;
353 } 353 }
354 354
355 void ViewCacheHelper::OnIOComplete(int result) { 355 void ViewCacheHelper::OnIOComplete(int result) {
356 DoLoop(result); 356 DoLoop(result);
357 } 357 }
358 358
359 } // namespace net. 359 } // namespace net.
OLDNEW
« no previous file with comments | « net/url_request/url_request_job.cc ('k') | net/websockets/websocket_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698