Chromium Code Reviews| 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 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DOCUMENTS_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DOCUMENTS_SERVICE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DOCUMENTS_SERVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DOCUMENTS_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/callback.h" | |
| 12 #include "base/file_path.h" | |
| 10 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/platform_file.h" | |
| 16 #include "base/values.h" | |
| 12 #include "chrome/browser/chromeos/gdata/gdata_auth_service.h" | 17 #include "chrome/browser/chromeos/gdata/gdata_auth_service.h" |
| 18 #include "chrome/browser/chromeos/gdata/gdata_documents_service.h" | |
|
achuithb
2012/08/07 23:14:21
Isn't this gdata_documents_service.h?
| |
| 13 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" | 19 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" |
| 14 #include "chrome/browser/chromeos/gdata/gdata_params.h" | 20 #include "chrome/browser/chromeos/gdata/gdata_upload_file_info.h" |
| 21 #include "googleurl/src/gurl.h" | |
| 22 #include "net/base/io_buffer.h" | |
| 15 | 23 |
| 16 class FilePath; | 24 class FilePath; |
| 17 class GURL; | 25 class GURL; |
| 18 class Profile; | 26 class Profile; |
| 19 | 27 |
| 20 namespace gdata { | 28 namespace gdata { |
| 21 | 29 |
| 30 class GDataEntry; | |
| 22 class GDataOperationInterface; | 31 class GDataOperationInterface; |
| 23 class GDataOperationRegistry; | 32 class GDataOperationRegistry; |
| 24 class GDataOperationRunner; | 33 class GDataOperationRunner; |
| 34 struct ResumeUploadResponse; | |
| 25 | 35 |
| 26 // Document export format. | 36 // Document export format. |
| 27 enum DocumentExportFormat { | 37 enum DocumentExportFormat { |
| 28 PDF, // Portable Document Format. (all documents) | 38 PDF, // Portable Document Format. (all documents) |
| 29 PNG, // Portable Networks Graphic Image Format (all documents) | 39 PNG, // Portable Networks Graphic Image Format (all documents) |
| 30 HTML, // HTML Format (text documents and spreadsheets). | 40 HTML, // HTML Format (text documents and spreadsheets). |
| 31 TXT, // Text file (text documents and presentations). | 41 TXT, // Text file (text documents and presentations). |
| 32 DOC, // Word (text documents only). | 42 DOC, // Word (text documents only). |
| 33 ODT, // Open Document Format (text documents only). | 43 ODT, // Open Document Format (text documents only). |
| 34 RTF, // Rich Text Format (text documents only). | 44 RTF, // Rich Text Format (text documents only). |
| 35 ZIP, // ZIP archive (text documents only). Contains the images (if any) | 45 ZIP, // ZIP archive (text documents only). Contains the images (if any) |
| 36 // used in the document as well as a .html file containing the | 46 // used in the document as well as a .html file containing the |
| 37 // document's text. | 47 // document's text. |
| 38 JPEG, // JPEG (drawings only). | 48 JPEG, // JPEG (drawings only). |
| 39 SVG, // Scalable Vector Graphics Image Format (drawings only). | 49 SVG, // Scalable Vector Graphics Image Format (drawings only). |
| 40 PPT, // Powerpoint (presentations only). | 50 PPT, // Powerpoint (presentations only). |
| 41 XLS, // Excel (spreadsheets only). | 51 XLS, // Excel (spreadsheets only). |
| 42 CSV, // Excel (spreadsheets only). | 52 CSV, // Excel (spreadsheets only). |
| 43 ODS, // Open Document Spreadsheet (spreadsheets only). | 53 ODS, // Open Document Spreadsheet (spreadsheets only). |
| 44 TSV, // Tab Separated Value (spreadsheets only). Only the first worksheet | 54 TSV, // Tab Separated Value (spreadsheets only). Only the first worksheet |
| 45 // is returned in TSV by default. | 55 // is returned in TSV by default. |
| 46 }; | 56 }; |
| 47 | 57 |
| 58 // Callback type for DocumentServiceInterface::GetDocuments. | |
| 59 // Note: feed_data argument should be passed using base::Passed(&feed_data), not | |
| 60 // feed_data.Pass(). | |
| 61 typedef base::Callback<void(GDataErrorCode error, | |
| 62 scoped_ptr<base::Value> feed_data)> GetDataCallback; | |
| 63 | |
| 64 // Callback type for Delete/Move DocumentServiceInterface calls. | |
| 65 typedef base::Callback<void(GDataErrorCode error, | |
| 66 const GURL& document_url)> EntryActionCallback; | |
| 67 | |
| 68 // Callback type for DownloadDocument/DownloadFile DocumentServiceInterface | |
| 69 // calls. | |
| 70 typedef base::Callback<void(GDataErrorCode error, | |
| 71 const GURL& content_url, | |
| 72 const FilePath& temp_file)> DownloadActionCallback; | |
| 73 | |
| 74 // Callback type for getting download data from DownloadFile | |
| 75 // DocumentServiceInterface calls. | |
| 76 typedef base::Callback<void( | |
| 77 GDataErrorCode error, | |
| 78 scoped_ptr<std::string> download_data)> GetDownloadDataCallback; | |
| 79 | |
| 80 // Callback type for DocumentServiceInterface::InitiateUpload. | |
| 81 typedef base::Callback<void(GDataErrorCode error, | |
| 82 const GURL& upload_url)> InitiateUploadCallback; | |
| 83 | |
| 84 // Callback type for DocumentServiceInterface::ResumeUpload. | |
| 85 typedef base::Callback<void( | |
| 86 const ResumeUploadResponse& response, | |
| 87 scoped_ptr<gdata::DocumentEntry> new_entry)> ResumeUploadCallback; | |
| 88 | |
| 89 // Callback type used to get result of file search. | |
| 90 // If |error| is not PLATFORM_FILE_OK, |entry| is set to NULL. | |
| 91 typedef base::Callback<void(GDataFileError error, GDataEntry* entry)> | |
| 92 FindEntryCallback; | |
| 93 | |
| 94 // Struct for response to ResumeUpload. | |
| 95 struct ResumeUploadResponse { | |
| 96 ResumeUploadResponse(GDataErrorCode code, | |
| 97 int64 start_range_received, | |
| 98 int64 end_range_received); | |
| 99 ~ResumeUploadResponse(); | |
| 100 | |
| 101 GDataErrorCode code; | |
| 102 int64 start_range_received; | |
| 103 int64 end_range_received; | |
| 104 FilePath virtual_path; | |
| 105 }; | |
| 106 | |
| 107 // Struct for passing params needed for DocumentsService::ResumeUpload() calls. | |
| 108 struct ResumeUploadParams { | |
| 109 ResumeUploadParams(UploadMode upload_mode, | |
| 110 int64 start_range, | |
| 111 int64 end_range, | |
| 112 int64 content_length, | |
| 113 const std::string& content_type, | |
| 114 scoped_refptr<net::IOBuffer> buf, | |
| 115 const GURL& upload_location, | |
| 116 const FilePath& virtual_path); | |
| 117 ~ResumeUploadParams(); | |
| 118 | |
| 119 UploadMode upload_mode; // Mode of the upload. | |
| 120 int64 start_range; // Start of range of contents currently stored in |buf|. | |
| 121 int64 end_range; // End of range of contents currently stored in |buf|. | |
| 122 int64 content_length; // File content-Length. | |
| 123 std::string content_type; // Content-Type of file. | |
| 124 scoped_refptr<net::IOBuffer> buf; // Holds current content to be uploaded. | |
| 125 GURL upload_location; // Url of where to upload the file to. | |
| 126 // Virtual GData path of the file seen in the UI. Not necessary for | |
| 127 // resuming an upload, but used for adding an entry to | |
| 128 // GDataOperationRegistry. | |
| 129 FilePath virtual_path; | |
| 130 }; | |
| 131 | |
| 132 // Struct for passing params needed for DocumentsService::InitiateUpload() | |
| 133 // calls. | |
| 134 // | |
| 135 // When uploading a new file (UPLOAD_NEW_FILE): | |
| 136 // - |title| should be set. | |
| 137 // - |upload_location| should be the upload_url() of the parent directory. | |
| 138 // | |
| 139 // When updating an existing file (UPLOAD_EXISTING_FILE): | |
| 140 // - |title| should be empty | |
| 141 // - |upload_location| should be the upload_url() of the existing file. | |
| 142 struct InitiateUploadParams { | |
| 143 InitiateUploadParams(UploadMode upload_mode, | |
| 144 const std::string& title, | |
| 145 const std::string& content_type, | |
| 146 int64 content_length, | |
| 147 const GURL& upload_location, | |
| 148 const FilePath& virtual_path); | |
| 149 ~InitiateUploadParams(); | |
| 150 | |
| 151 UploadMode upload_mode; | |
| 152 std::string title; | |
| 153 std::string content_type; | |
| 154 int64 content_length; | |
| 155 GURL upload_location; | |
| 156 const FilePath& virtual_path; | |
| 157 }; | |
| 158 | |
| 48 // This defines an interface for sharing by DocumentService and | 159 // This defines an interface for sharing by DocumentService and |
| 49 // MockDocumentService so that we can do testing of clients of DocumentService. | 160 // MockDocumentService so that we can do testing of clients of DocumentService. |
| 50 // | 161 // |
| 51 // All functions must be called on UI thread. DocumentService is built on top | 162 // All functions must be called on UI thread. DocumentService is built on top |
| 52 // of URLFetcher that runs on UI thread. | 163 // of URLFetcher that runs on UI thread. |
| 53 // | 164 // |
| 54 // TODO(zel,benchan): Make the terminology/naming convention (e.g. file vs | 165 // TODO(zel,benchan): Make the terminology/naming convention (e.g. file vs |
| 55 // document vs resource, directory vs collection) more consistent and precise. | 166 // document vs resource, directory vs collection) more consistent and precise. |
| 56 class DocumentsServiceInterface { | 167 class DocumentsServiceInterface { |
| 57 public: | 168 public: |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 271 Profile* profile_; | 382 Profile* profile_; |
| 272 | 383 |
| 273 scoped_ptr<GDataOperationRunner> runner_; | 384 scoped_ptr<GDataOperationRunner> runner_; |
| 274 | 385 |
| 275 DISALLOW_COPY_AND_ASSIGN(DocumentsService); | 386 DISALLOW_COPY_AND_ASSIGN(DocumentsService); |
| 276 }; | 387 }; |
| 277 | 388 |
| 278 } // namespace gdata | 389 } // namespace gdata |
| 279 | 390 |
| 280 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DOCUMENTS_SERVICE_H_ | 391 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DOCUMENTS_SERVICE_H_ |
| OLD | NEW |