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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_protocol_handler.cc

Issue 10386206: RefCounted types should not have public destructors, chromeos edition (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to r143931 Created 8 years, 5 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 | Annotate | Revision Log
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 "chrome/browser/chromeos/gdata/gdata_protocol_handler.h" 5 #include "chrome/browser/chromeos/gdata/gdata_protocol_handler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 system_service->docs_service()->operation_registry()->CancelForFilePath( 120 system_service->docs_service()->operation_registry()->CancelForFilePath(
121 gdata_file_path); 121 gdata_file_path);
122 } 122 }
123 123
124 // GDataURLRequesetJob is the gateway between network-level drive://... 124 // GDataURLRequesetJob is the gateway between network-level drive://...
125 // requests for gdata resources and GDataFileSytem. It exposes content URLs 125 // requests for gdata resources and GDataFileSytem. It exposes content URLs
126 // formatted as drive://<resource-id>. 126 // formatted as drive://<resource-id>.
127 class GDataURLRequestJob : public net::URLRequestJob { 127 class GDataURLRequestJob : public net::URLRequestJob {
128 public: 128 public:
129 explicit GDataURLRequestJob(net::URLRequest* request); 129 explicit GDataURLRequestJob(net::URLRequest* request);
130 virtual ~GDataURLRequestJob();
131 130
132 // net::URLRequestJob overrides: 131 // net::URLRequestJob overrides:
133 virtual void Start() OVERRIDE; 132 virtual void Start() OVERRIDE;
134 virtual void Kill() OVERRIDE; 133 virtual void Kill() OVERRIDE;
135 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; 134 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE;
136 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE; 135 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE;
137 virtual int GetResponseCode() const OVERRIDE; 136 virtual int GetResponseCode() const OVERRIDE;
138 virtual bool ReadRawData(net::IOBuffer* buf, 137 virtual bool ReadRawData(net::IOBuffer* buf,
139 int buf_size, 138 int buf_size,
140 int* bytes_read) OVERRIDE; 139 int* bytes_read) OVERRIDE;
141 140
141 protected:
142 virtual ~GDataURLRequestJob();
143
142 private: 144 private:
143 // Helper for Start() to let us start asynchronously. 145 // Helper for Start() to let us start asynchronously.
144 void StartAsync(GDataFileSystem** file_system); 146 void StartAsync(GDataFileSystem** file_system);
145 147
146 // Helper methods for Delegate::OnUrlFetchDownloadData and ReadRawData to 148 // Helper methods for Delegate::OnUrlFetchDownloadData and ReadRawData to
147 // receive download data and copy to response buffer. 149 // receive download data and copy to response buffer.
148 // For detailed description of logic, refer to comments in definitions of 150 // For detailed description of logic, refer to comments in definitions of
149 // Start() and ReadRawData(). 151 // Start() and ReadRawData().
150 152
151 void OnUrlFetchDownloadData(GDataErrorCode error, 153 void OnUrlFetchDownloadData(GDataErrorCode error,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 headers_set_(false), 228 headers_set_(false),
227 initial_file_size_(0), 229 initial_file_size_(0),
228 remaining_bytes_(0), 230 remaining_bytes_(0),
229 streaming_download_(false), 231 streaming_download_(false),
230 download_growable_buf_(new net::GrowableIOBuffer) { 232 download_growable_buf_(new net::GrowableIOBuffer) {
231 download_growable_buf_->SetCapacity(kInitialDownloadBufferSizeInBytes); 233 download_growable_buf_->SetCapacity(kInitialDownloadBufferSizeInBytes);
232 download_drainable_buf_ = new net::DrainableIOBuffer( 234 download_drainable_buf_ = new net::DrainableIOBuffer(
233 download_growable_buf_, download_growable_buf_->capacity()); 235 download_growable_buf_, download_growable_buf_->capacity());
234 } 236 }
235 237
236 GDataURLRequestJob::~GDataURLRequestJob() {
237 CloseFileStream();
238 }
239
240 void GDataURLRequestJob::Start() { 238 void GDataURLRequestJob::Start() {
241 DVLOG(1) << "Starting request"; 239 DVLOG(1) << "Starting request";
242 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 240 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
243 241
244 // As per pattern shared by most net::URLRequestJob implementations, we start 242 // As per pattern shared by most net::URLRequestJob implementations, we start
245 // asynchronously. 243 // asynchronously.
246 244
247 // Here is how Start and its helper methods work: 245 // Here is how Start and its helper methods work:
248 // 1) Post task to UI thread to get file system. 246 // 1) Post task to UI thread to get file system.
249 // Note: should we not post task to get file system later, start request 247 // Note: should we not post task to get file system later, start request
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 DVLOG(1) << "ReadRawData: out with " 452 DVLOG(1) << "ReadRawData: out with "
455 << (rc ? "has" : "no") 453 << (rc ? "has" : "no")
456 << "_data, bytes_read=" << *bytes_read 454 << "_data, bytes_read=" << *bytes_read
457 << ", buf_remaining=" 455 << ", buf_remaining="
458 << (read_buf_ ? read_buf_->BytesRemaining() : 0) 456 << (read_buf_ ? read_buf_->BytesRemaining() : 0)
459 << ", " << (streaming_download_ ? "download" : "file") 457 << ", " << (streaming_download_ ? "download" : "file")
460 << "_remaining=" << remaining_bytes_; 458 << "_remaining=" << remaining_bytes_;
461 return rc; 459 return rc;
462 } 460 }
463 461
462 //======================= GDataURLRequestJob protected methods ================
463
464 GDataURLRequestJob::~GDataURLRequestJob() {
465 CloseFileStream();
466 }
467
464 //======================= GDataURLRequestJob private methods =================== 468 //======================= GDataURLRequestJob private methods ===================
465 469
466 void GDataURLRequestJob::StartAsync(GDataFileSystem** file_system) { 470 void GDataURLRequestJob::StartAsync(GDataFileSystem** file_system) {
467 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 471 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
468 472
469 file_system_ = *file_system; 473 file_system_ = *file_system;
470 474
471 if (!request_ || !file_system_) { 475 if (!request_ || !file_system_) {
472 LOG(WARNING) << "Failed to start request: null " 476 LOG(WARNING) << "Failed to start request: null "
473 << (!request_ ? "request" : "file system"); 477 << (!request_ ? "request" : "file system");
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 GDataProtocolHandler::~GDataProtocolHandler() { 924 GDataProtocolHandler::~GDataProtocolHandler() {
921 } 925 }
922 926
923 net::URLRequestJob* GDataProtocolHandler::MaybeCreateJob( 927 net::URLRequestJob* GDataProtocolHandler::MaybeCreateJob(
924 net::URLRequest* request) const { 928 net::URLRequest* request) const {
925 DVLOG(1) << "Handling url: " << request->url().spec(); 929 DVLOG(1) << "Handling url: " << request->url().spec();
926 return new GDataURLRequestJob(request); 930 return new GDataURLRequestJob(request);
927 } 931 }
928 932
929 } // namespace gdata 933 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698