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

Side by Side Diff: chrome/browser/renderer_host/download_resource_handler.cc

Issue 159561: Add CHECKs to the ResourceHandler derived classes to see which is returning a NULL IOBuffer:data_. (Closed)
Patch Set: Add comments. Add missing .h file. Created 11 years, 4 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/browser/renderer_host/download_resource_handler.h" 5 #include "chrome/browser/renderer_host/download_resource_handler.h"
6 6
7 #include "base/logging.h"
7 #include "chrome/browser/download/download_file.h" 8 #include "chrome/browser/download/download_file.h"
8 #include "chrome/browser/download/download_manager.h" 9 #include "chrome/browser/download/download_manager.h"
9 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" 10 #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
10 #include "net/base/io_buffer.h" 11 #include "net/base/io_buffer.h"
11 #include "net/url_request/url_request_context.h" 12 #include "net/url_request/url_request_context.h"
12 13
13 DownloadResourceHandler::DownloadResourceHandler(ResourceDispatcherHost* rdh, 14 DownloadResourceHandler::DownloadResourceHandler(ResourceDispatcherHost* rdh,
14 int render_process_host_id, 15 int render_process_host_id,
15 int render_view_id, 16 int render_view_id,
16 int request_id, 17 int request_id,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // Create a new buffer, which will be handed to the download thread for file 77 // Create a new buffer, which will be handed to the download thread for file
77 // writing and deletion. 78 // writing and deletion.
78 bool DownloadResourceHandler::OnWillRead(int request_id, net::IOBuffer** buf, 79 bool DownloadResourceHandler::OnWillRead(int request_id, net::IOBuffer** buf,
79 int* buf_size, int min_size) { 80 int* buf_size, int min_size) {
80 DCHECK(buf && buf_size); 81 DCHECK(buf && buf_size);
81 if (!read_buffer_) { 82 if (!read_buffer_) {
82 *buf_size = min_size < 0 ? kReadBufSize : min_size; 83 *buf_size = min_size < 0 ? kReadBufSize : min_size;
83 read_buffer_ = new net::IOBuffer(*buf_size); 84 read_buffer_ = new net::IOBuffer(*buf_size);
84 } 85 }
85 *buf = read_buffer_.get(); 86 *buf = read_buffer_.get();
87 // TODO(willchan): Remove after debugging bug 16371.
88 CHECK(read_buffer_->data());
86 return true; 89 return true;
87 } 90 }
88 91
89 // Pass the buffer to the download file writer. 92 // Pass the buffer to the download file writer.
90 bool DownloadResourceHandler::OnReadCompleted(int request_id, int* bytes_read) { 93 bool DownloadResourceHandler::OnReadCompleted(int request_id, int* bytes_read) {
91 if (!*bytes_read) 94 if (!*bytes_read)
92 return true; 95 return true;
93 DCHECK(read_buffer_); 96 DCHECK(read_buffer_);
94 AutoLock auto_lock(buffer_->lock); 97 AutoLock auto_lock(buffer_->lock);
95 bool need_update = buffer_->contents.empty(); 98 bool need_update = buffer_->contents.empty();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 should_pause); 169 should_pause);
167 is_paused_ = should_pause; 170 is_paused_ = should_pause;
168 } 171 }
169 } 172 }
170 173
171 void DownloadResourceHandler::StartPauseTimer() { 174 void DownloadResourceHandler::StartPauseTimer() {
172 if (!pause_timer_.IsRunning()) 175 if (!pause_timer_.IsRunning())
173 pause_timer_.Start(base::TimeDelta::FromMilliseconds(kThrottleTimeMs), this, 176 pause_timer_.Start(base::TimeDelta::FromMilliseconds(kThrottleTimeMs), this,
174 &DownloadResourceHandler::CheckWriteProgress); 177 &DownloadResourceHandler::CheckWriteProgress);
175 } 178 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698