| 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" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "base/threading/sequenced_worker_pool.h" | 17 #include "base/threading/sequenced_worker_pool.h" |
| 18 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
| 19 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" |
| 20 #include "chrome/browser/chromeos/gdata/gdata_files.h" |
| 21 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" |
| 22 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/profiles/profile_manager.h" | 24 #include "chrome/browser/profiles/profile_manager.h" |
| 21 #include "chrome/browser/chromeos/gdata/gdata_files.h" | |
| 22 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" | |
| 23 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" | |
| 24 #include "chrome/browser/chromeos/gdata/gdata_util.h" | |
| 25 #include "chrome/common/url_constants.h" | 25 #include "chrome/common/url_constants.h" |
| 26 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
| 27 #include "net/base/escape.h" | 27 #include "net/base/escape.h" |
| 28 #include "net/base/file_stream.h" | 28 #include "net/base/file_stream.h" |
| 29 #include "net/base/net_errors.h" | 29 #include "net/base/net_errors.h" |
| 30 #include "net/http/http_request_headers.h" | 30 #include "net/http/http_request_headers.h" |
| 31 #include "net/http/http_response_headers.h" | 31 #include "net/http/http_response_headers.h" |
| 32 #include "net/http/http_response_info.h" | 32 #include "net/http/http_response_info.h" |
| 33 #include "net/url_request/url_request.h" | 33 #include "net/url_request/url_request.h" |
| 34 #include "net/url_request/url_request_job.h" | 34 #include "net/url_request/url_request_job.h" |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 // 4) Otherwise, parse request url to get resource id and file name. | 229 // 4) Otherwise, parse request url to get resource id and file name. |
| 230 // 5) Find file from file system to get its mime type, gdata file path and | 230 // 5) Find file from file system to get its mime type, gdata file path and |
| 231 // size of physical file. | 231 // size of physical file. |
| 232 // 6) Get file from file system asynchronously with both GetFileCallback and | 232 // 6) Get file from file system asynchronously with both GetFileCallback and |
| 233 // GetDownloadDataCallback - this would either get it from cache or | 233 // GetDownloadDataCallback - this would either get it from cache or |
| 234 // download it from gdata. | 234 // download it from gdata. |
| 235 // 7) If file is downloaded from gdata: | 235 // 7) If file is downloaded from gdata: |
| 236 // 7.1) Whenever content::URLFetcherCore::OnReadCompleted() receives a part | 236 // 7.1) Whenever content::URLFetcherCore::OnReadCompleted() receives a part |
| 237 // of the response, it invokes | 237 // of the response, it invokes |
| 238 // constent::URLFetcherDelegate::OnURLFetchDownloadData() if | 238 // constent::URLFetcherDelegate::OnURLFetchDownloadData() if |
| 239 // content::URLFetcherDelegate::ShouldSendDownloadData() is true. | 239 // net::URLFetcherDelegate::ShouldSendDownloadData() is true. |
| 240 // 7.2) gdata::DownloadFileOperation overrides the default implementations | 240 // 7.2) gdata::DownloadFileOperation overrides the default implementations |
| 241 // of the following methods of content::URLFetcherDelegate: | 241 // of the following methods of net::URLFetcherDelegate: |
| 242 // - ShouldSendDownloadData(): returns true for non-null | 242 // - ShouldSendDownloadData(): returns true for non-null |
| 243 // GetDownloadDataCallback. | 243 // GetDownloadDataCallback. |
| 244 // - OnURLFetchDownloadData(): invokes non-null | 244 // - OnURLFetchDownloadData(): invokes non-null |
| 245 // GetDownloadDataCallback | 245 // GetDownloadDataCallback |
| 246 // 7.3) GDataProtolHandler::OnURLFetchDownloadData (i.e. this class) | 246 // 7.3) GDataProtolHandler::OnURLFetchDownloadData (i.e. this class) |
| 247 // is at the end of the invocation chain and actually implements the | 247 // is at the end of the invocation chain and actually implements the |
| 248 // method. | 248 // method. |
| 249 // 7.4) Copies the formal download data into a growable-drainable dowload | 249 // 7.4) Copies the formal download data into a growable-drainable dowload |
| 250 // IOBuffer | 250 // IOBuffer |
| 251 // - IOBuffer has initial size 4096, same as buffer used in | 251 // - IOBuffer has initial size 4096, same as buffer used in |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 GDataProtocolHandler::~GDataProtocolHandler() { | 899 GDataProtocolHandler::~GDataProtocolHandler() { |
| 900 } | 900 } |
| 901 | 901 |
| 902 net::URLRequestJob* GDataProtocolHandler::MaybeCreateJob( | 902 net::URLRequestJob* GDataProtocolHandler::MaybeCreateJob( |
| 903 net::URLRequest* request) const { | 903 net::URLRequest* request) const { |
| 904 DVLOG(1) << "Handling url: " << request->url().spec(); | 904 DVLOG(1) << "Handling url: " << request->url().spec(); |
| 905 return new GDataURLRequestJob(request); | 905 return new GDataURLRequestJob(request); |
| 906 } | 906 } |
| 907 | 907 |
| 908 } // namespace gdata | 908 } // namespace gdata |
| OLD | NEW |