| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_PARAMS_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_PARAMS_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/callback.h" | |
| 12 #include "base/file_path.h" | |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "base/memory/weak_ptr.h" | |
| 15 #include "base/platform_file.h" | |
| 16 #include "base/values.h" | |
| 17 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" | |
| 18 #include "chrome/browser/chromeos/gdata/gdata_upload_file_info.h" | |
| 19 #include "googleurl/src/gurl.h" | |
| 20 #include "net/base/io_buffer.h" | |
| 21 | |
| 22 namespace gdata { | |
| 23 | |
| 24 class GDataEntry; | |
| 25 struct ResumeUploadResponse; | |
| 26 | |
| 27 // Different callback types for various functionalities in DocumentsService. | |
| 28 | |
| 29 // Callback type for authentication related DocumentService calls. | |
| 30 typedef base::Callback<void(GDataErrorCode error, | |
| 31 const std::string& token)> AuthStatusCallback; | |
| 32 | |
| 33 // Callback type for DocumentServiceInterface::GetDocuments. | |
| 34 // Note: feed_data argument should be passed using base::Passed(&feed_data), not | |
| 35 // feed_data.Pass(). | |
| 36 typedef base::Callback<void(GDataErrorCode error, | |
| 37 scoped_ptr<base::Value> feed_data)> GetDataCallback; | |
| 38 | |
| 39 // Callback type for Delete/Move DocumentServiceInterface calls. | |
| 40 typedef base::Callback<void(GDataErrorCode error, | |
| 41 const GURL& document_url)> EntryActionCallback; | |
| 42 | |
| 43 // Callback type for DownloadDocument/DownloadFile DocumentServiceInterface | |
| 44 // calls. | |
| 45 typedef base::Callback<void(GDataErrorCode error, | |
| 46 const GURL& content_url, | |
| 47 const FilePath& temp_file)> DownloadActionCallback; | |
| 48 | |
| 49 // Callback type for getting download data from DownloadFile | |
| 50 // DocumentServiceInterface calls. | |
| 51 typedef base::Callback<void( | |
| 52 GDataErrorCode error, | |
| 53 scoped_ptr<std::string> download_data)> GetDownloadDataCallback; | |
| 54 | |
| 55 // Callback type for DocumentServiceInterface::InitiateUpload. | |
| 56 typedef base::Callback<void(GDataErrorCode error, | |
| 57 const GURL& upload_url)> InitiateUploadCallback; | |
| 58 | |
| 59 // Callback type for DocumentServiceInterface::ResumeUpload. | |
| 60 typedef base::Callback<void( | |
| 61 const ResumeUploadResponse& response, | |
| 62 scoped_ptr<gdata::DocumentEntry> new_entry)> ResumeUploadCallback; | |
| 63 | |
| 64 // Callback type used to get result of file search. | |
| 65 // If |error| is not PLATFORM_FILE_OK, |entry| is set to NULL. | |
| 66 typedef base::Callback<void(GDataFileError error, GDataEntry* entry)> | |
| 67 FindEntryCallback; | |
| 68 | |
| 69 | |
| 70 // Struct for response to ResumeUpload. | |
| 71 struct ResumeUploadResponse { | |
| 72 ResumeUploadResponse(GDataErrorCode code, | |
| 73 int64 start_range_received, | |
| 74 int64 end_range_received); | |
| 75 ~ResumeUploadResponse(); | |
| 76 | |
| 77 GDataErrorCode code; | |
| 78 int64 start_range_received; | |
| 79 int64 end_range_received; | |
| 80 FilePath virtual_path; | |
| 81 }; | |
| 82 | |
| 83 // Struct for passing params needed for DocumentsService::ResumeUpload() calls. | |
| 84 struct ResumeUploadParams { | |
| 85 ResumeUploadParams(UploadMode upload_mode, | |
| 86 int64 start_range, | |
| 87 int64 end_range, | |
| 88 int64 content_length, | |
| 89 const std::string& content_type, | |
| 90 scoped_refptr<net::IOBuffer> buf, | |
| 91 const GURL& upload_location, | |
| 92 const FilePath& virtual_path); | |
| 93 ~ResumeUploadParams(); | |
| 94 | |
| 95 UploadMode upload_mode; // Mode of the upload. | |
| 96 int64 start_range; // Start of range of contents currently stored in |buf|. | |
| 97 int64 end_range; // End of range of contents currently stored in |buf|. | |
| 98 int64 content_length; // File content-Length. | |
| 99 std::string content_type; // Content-Type of file. | |
| 100 scoped_refptr<net::IOBuffer> buf; // Holds current content to be uploaded. | |
| 101 GURL upload_location; // Url of where to upload the file to. | |
| 102 // Virtual GData path of the file seen in the UI. Not necessary for | |
| 103 // resuming an upload, but used for adding an entry to | |
| 104 // GDataOperationRegistry. | |
| 105 FilePath virtual_path; | |
| 106 }; | |
| 107 | |
| 108 // Struct for passing params needed for DocumentsService::InitiateUpload() | |
| 109 // calls. | |
| 110 // | |
| 111 // When uploading a new file (UPLOAD_NEW_FILE): | |
| 112 // - |title| should be set. | |
| 113 // - |upload_location| should be the upload_url() of the parent directory. | |
| 114 // | |
| 115 // When updating an existing file (UPLOAD_EXISTING_FILE): | |
| 116 // - |title| should be empty | |
| 117 // - |upload_location| should be the upload_url() of the existing file. | |
| 118 struct InitiateUploadParams { | |
| 119 InitiateUploadParams(UploadMode upload_mode, | |
| 120 const std::string& title, | |
| 121 const std::string& content_type, | |
| 122 int64 content_length, | |
| 123 const GURL& upload_location, | |
| 124 const FilePath& virtual_path); | |
| 125 ~InitiateUploadParams(); | |
| 126 | |
| 127 UploadMode upload_mode; | |
| 128 std::string title; | |
| 129 std::string content_type; | |
| 130 int64 content_length; | |
| 131 GURL upload_location; | |
| 132 const FilePath& virtual_path; | |
| 133 }; | |
| 134 | |
| 135 // Defines set of parameters sent to callback OnProtoLoaded(). | |
| 136 struct LoadRootFeedParams { | |
| 137 LoadRootFeedParams( | |
| 138 FilePath search_file_path, | |
| 139 bool should_load_from_server, | |
| 140 const FindEntryCallback& callback); | |
| 141 ~LoadRootFeedParams(); | |
| 142 | |
| 143 FilePath search_file_path; | |
| 144 bool should_load_from_server; | |
| 145 std::string proto; | |
| 146 GDataFileError load_error; | |
| 147 base::Time last_modified; | |
| 148 // Time when filesystem began to be loaded from disk. | |
| 149 base::Time load_start_time; | |
| 150 const FindEntryCallback callback; | |
| 151 }; | |
| 152 | |
| 153 } // namespace gdata | |
| 154 | |
| 155 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_PARAMS_H_ | |
| OLD | NEW |