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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 // should still be asynchronous, so that all error reporting and data | 253 // should still be asynchronous, so that all error reporting and data |
254 // callbacks happen as they would for network requests, so we should still | 254 // callbacks happen as they would for network requests, so we should still |
255 // post task to same thread to actually start request. | 255 // post task to same thread to actually start request. |
256 // 2) Reply task StartAsync is invoked. | 256 // 2) Reply task StartAsync is invoked. |
257 // 3) If unable to get file system or request method is not GET, report start | 257 // 3) If unable to get file system or request method is not GET, report start |
258 // error and bail out. | 258 // error and bail out. |
259 // 4) Otherwise, parse request url to get resource id and file name. | 259 // 4) Otherwise, parse request url to get resource id and file name. |
260 // 5) Find file from file system to get its mime type, gdata file path and | 260 // 5) Find file from file system to get its mime type, gdata file path and |
261 // size of physical file. | 261 // size of physical file. |
262 // 6) Get file from file system asynchronously with both GetFileCallback and | 262 // 6) Get file from file system asynchronously with both GetFileCallback and |
263 // GetDownloadDataCallback - this would either get it from cache or | 263 // GetContentCallback - this would either get it from cache or |
264 // download it from gdata. | 264 // download it from gdata. |
265 // 7) If file is downloaded from gdata: | 265 // 7) If file is downloaded from gdata: |
266 // 7.1) Whenever net::URLFetcherCore::OnReadCompleted() receives a part | 266 // 7.1) Whenever net::URLFetcherCore::OnReadCompleted() receives a part |
267 // of the response, it invokes | 267 // of the response, it invokes |
268 // constent::URLFetcherDelegate::OnURLFetchDownloadData() if | 268 // constent::URLFetcherDelegate::OnURLFetchDownloadData() if |
269 // net::URLFetcherDelegate::ShouldSendDownloadData() is true. | 269 // net::URLFetcherDelegate::ShouldSendDownloadData() is true. |
270 // 7.2) gdata::DownloadFileOperation overrides the default implementations | 270 // 7.2) gdata::DownloadFileOperation overrides the default implementations |
271 // of the following methods of net::URLFetcherDelegate: | 271 // of the following methods of net::URLFetcherDelegate: |
272 // - ShouldSendDownloadData(): returns true for non-null | 272 // - ShouldSendDownloadData(): returns true for non-null |
273 // GetDownloadDataCallback. | 273 // GetContentCallback. |
274 // - OnURLFetchDownloadData(): invokes non-null | 274 // - OnURLFetchDownloadData(): invokes non-null |
275 // GetDownloadDataCallback | 275 // GetContentCallback |
276 // 7.3) GDataProtolHandler::OnURLFetchDownloadData (i.e. this class) | 276 // 7.3) GDataProtolHandler::OnURLFetchDownloadData (i.e. this class) |
277 // is at the end of the invocation chain and actually implements the | 277 // is at the end of the invocation chain and actually implements the |
278 // method. | 278 // method. |
279 // 7.4) Copies the formal download data into a growable-drainable dowload | 279 // 7.4) Copies the formal download data into a growable-drainable dowload |
280 // IOBuffer | 280 // IOBuffer |
281 // - IOBuffer has initial size 4096, same as buffer used in | 281 // - IOBuffer has initial size 4096, same as buffer used in |
282 // net::URLFetcherCore::OnReadCompleted. | 282 // net::URLFetcherCore::OnReadCompleted. |
283 // - We may end up with multiple chunks, so we use GrowableIOBuffer. | 283 // - We may end up with multiple chunks, so we use GrowableIOBuffer. |
284 // - We then wrap the growable buffer within a DrainableIOBuffer for | 284 // - We then wrap the growable buffer within a DrainableIOBuffer for |
285 // ease of progressively writing into the buffer. | 285 // ease of progressively writing into the buffer. |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 GDataProtocolHandler::~GDataProtocolHandler() { | 933 GDataProtocolHandler::~GDataProtocolHandler() { |
934 } | 934 } |
935 | 935 |
936 net::URLRequestJob* GDataProtocolHandler::MaybeCreateJob( | 936 net::URLRequestJob* GDataProtocolHandler::MaybeCreateJob( |
937 net::URLRequest* request) const { | 937 net::URLRequest* request) const { |
938 DVLOG(1) << "Handling url: " << request->url().spec(); | 938 DVLOG(1) << "Handling url: " << request->url().spec(); |
939 return new GDataURLRequestJob(request); | 939 return new GDataURLRequestJob(request); |
940 } | 940 } |
941 | 941 |
942 } // namespace gdata | 942 } // namespace gdata |
OLD | NEW |