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