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

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

Issue 10855209: Refactoring: ProtocolHandler::MaybeCreateJob takes NetworkDelegate as argument (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: NetworkDelegate fixed almost everywhere Created 8 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 | 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 17 matching lines...) Expand all
28 #include "chrome/browser/profiles/profile_manager.h" 28 #include "chrome/browser/profiles/profile_manager.h"
29 #include "chrome/common/url_constants.h" 29 #include "chrome/common/url_constants.h"
30 #include "content/public/browser/browser_thread.h" 30 #include "content/public/browser/browser_thread.h"
31 #include "net/base/escape.h" 31 #include "net/base/escape.h"
32 #include "net/base/file_stream.h" 32 #include "net/base/file_stream.h"
33 #include "net/base/net_errors.h" 33 #include "net/base/net_errors.h"
34 #include "net/http/http_request_headers.h" 34 #include "net/http/http_request_headers.h"
35 #include "net/http/http_response_headers.h" 35 #include "net/http/http_response_headers.h"
36 #include "net/http/http_response_info.h" 36 #include "net/http/http_response_info.h"
37 #include "net/url_request/url_request.h" 37 #include "net/url_request/url_request.h"
38 #include "net/url_request/url_request_context.h"
39 #include "net/url_request/url_request_job.h" 38 #include "net/url_request/url_request_job.h"
40 39
41 using content::BrowserThread; 40 using content::BrowserThread;
42 41
43 namespace gdata { 42 namespace gdata {
44 43
45 namespace { 44 namespace {
46 45
47 const net::UnescapeRule::Type kUrlPathUnescapeMask = 46 const net::UnescapeRule::Type kUrlPathUnescapeMask =
48 net::UnescapeRule::SPACES | 47 net::UnescapeRule::SPACES |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 if (system_service) 123 if (system_service)
125 system_service->docs_service()->operation_registry()->CancelForFilePath( 124 system_service->docs_service()->operation_registry()->CancelForFilePath(
126 gdata_file_path); 125 gdata_file_path);
127 } 126 }
128 127
129 // GDataURLRequesetJob is the gateway between network-level drive://... 128 // GDataURLRequesetJob is the gateway between network-level drive://...
130 // requests for gdata resources and GDataFileSytem. It exposes content URLs 129 // requests for gdata resources and GDataFileSytem. It exposes content URLs
131 // formatted as drive://<resource-id>. 130 // formatted as drive://<resource-id>.
132 class GDataURLRequestJob : public net::URLRequestJob { 131 class GDataURLRequestJob : public net::URLRequestJob {
133 public: 132 public:
134 explicit GDataURLRequestJob(net::URLRequest* request); 133 GDataURLRequestJob(net::URLRequest* request,
134 net::NetworkDelegate* network_delegate);
135 135
136 // net::URLRequestJob overrides: 136 // net::URLRequestJob overrides:
137 virtual void Start() OVERRIDE; 137 virtual void Start() OVERRIDE;
138 virtual void Kill() OVERRIDE; 138 virtual void Kill() OVERRIDE;
139 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; 139 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE;
140 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE; 140 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE;
141 virtual int GetResponseCode() const OVERRIDE; 141 virtual int GetResponseCode() const OVERRIDE;
142 virtual bool ReadRawData(net::IOBuffer* buf, 142 virtual bool ReadRawData(net::IOBuffer* buf,
143 int buf_size, 143 int buf_size,
144 int* bytes_read) OVERRIDE; 144 int* bytes_read) OVERRIDE;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 scoped_ptr<net::FileStream> stream_; 218 scoped_ptr<net::FileStream> stream_;
219 scoped_refptr<net::DrainableIOBuffer> read_buf_; 219 scoped_refptr<net::DrainableIOBuffer> read_buf_;
220 scoped_ptr<net::HttpResponseInfo> response_info_; 220 scoped_ptr<net::HttpResponseInfo> response_info_;
221 bool streaming_download_; 221 bool streaming_download_;
222 scoped_refptr<net::GrowableIOBuffer> download_growable_buf_; 222 scoped_refptr<net::GrowableIOBuffer> download_growable_buf_;
223 scoped_refptr<net::DrainableIOBuffer> download_drainable_buf_; 223 scoped_refptr<net::DrainableIOBuffer> download_drainable_buf_;
224 224
225 DISALLOW_COPY_AND_ASSIGN(GDataURLRequestJob); 225 DISALLOW_COPY_AND_ASSIGN(GDataURLRequestJob);
226 }; 226 };
227 227
228 GDataURLRequestJob::GDataURLRequestJob(net::URLRequest* request) 228 GDataURLRequestJob::GDataURLRequestJob(net::URLRequest* request,
229 : net::URLRequestJob(request, request->context()->network_delegate()), 229 net::NetworkDelegate* network_delegate)
230 : net::URLRequestJob(request, network_delegate),
230 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST( 231 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(
231 new base::WeakPtrFactory<GDataURLRequestJob>(this))), 232 new base::WeakPtrFactory<GDataURLRequestJob>(this))),
232 file_system_(NULL), 233 file_system_(NULL),
233 error_(false), 234 error_(false),
234 headers_set_(false), 235 headers_set_(false),
235 initial_file_size_(0), 236 initial_file_size_(0),
236 remaining_bytes_(0), 237 remaining_bytes_(0),
237 streaming_download_(false), 238 streaming_download_(false),
238 download_growable_buf_(new net::GrowableIOBuffer) { 239 download_growable_buf_(new net::GrowableIOBuffer) {
239 download_growable_buf_->SetCapacity(kInitialDownloadBufferSizeInBytes); 240 download_growable_buf_->SetCapacity(kInitialDownloadBufferSizeInBytes);
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 /////////////////////////////////////////////////////////////////////////////// 929 ///////////////////////////////////////////////////////////////////////////////
929 // GDataProtocolHandler class 930 // GDataProtocolHandler class
930 931
931 GDataProtocolHandler::GDataProtocolHandler() { 932 GDataProtocolHandler::GDataProtocolHandler() {
932 } 933 }
933 934
934 GDataProtocolHandler::~GDataProtocolHandler() { 935 GDataProtocolHandler::~GDataProtocolHandler() {
935 } 936 }
936 937
937 net::URLRequestJob* GDataProtocolHandler::MaybeCreateJob( 938 net::URLRequestJob* GDataProtocolHandler::MaybeCreateJob(
938 net::URLRequest* request) const { 939 net::URLRequest* request, net::NetworkDelegate* network_delegate) const {
939 DVLOG(1) << "Handling url: " << request->url().spec(); 940 DVLOG(1) << "Handling url: " << request->url().spec();
940 return new GDataURLRequestJob(request); 941 return new GDataURLRequestJob(request, network_delegate);
941 } 942 }
942 943
943 } // namespace gdata 944 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698