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_GOOGLE_APIS_GDATA_WAPI_OPERATIONS_H_ | 5 #ifndef CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_OPERATIONS_H_ |
6 #define CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_OPERATIONS_H_ | 6 #define CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_OPERATIONS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 117 |
118 protected: | 118 protected: |
119 // UrlFetchOperationBase overrides. | 119 // UrlFetchOperationBase overrides. |
120 virtual GURL GetURL() const OVERRIDE; | 120 virtual GURL GetURL() const OVERRIDE; |
121 | 121 |
122 private: | 122 private: |
123 const GDataWapiUrlGenerator url_generator_; | 123 const GDataWapiUrlGenerator url_generator_; |
124 DISALLOW_COPY_AND_ASSIGN(GetAccountMetadataOperation); | 124 DISALLOW_COPY_AND_ASSIGN(GetAccountMetadataOperation); |
125 }; | 125 }; |
126 | 126 |
127 //============================ DownloadFileOperation =========================== | |
128 | |
129 // Callback type for DownloadHostedDocument/DownloadFile | |
130 // DocumentServiceInterface calls. | |
131 typedef base::Callback<void(GDataErrorCode error, | |
132 const FilePath& temp_file)> DownloadActionCallback; | |
133 | |
134 // This class performs the operation for downloading of a given document/file. | |
135 class DownloadFileOperation : public UrlFetchOperationBase { | |
136 public: | |
137 // download_action_callback: | |
138 // This callback is called when the download is complete. Must not be null. | |
139 // | |
140 // get_content_callback: | |
141 // This callback is called when some part of the content is | |
142 // read. Used to read the download content progressively. May be null. | |
143 // | |
144 // content_url: | |
145 // Specifies the target file to download. | |
146 // | |
147 // drive_file_path: | |
148 // Specifies the drive path of the target file. Shown in UI. | |
149 // TODO(satorux): Remove the drive file path hack. crbug.com/163296 | |
150 // | |
151 // output_file_path: | |
152 // Specifies the file path to save the downloaded file. | |
153 // | |
154 DownloadFileOperation( | |
155 OperationRegistry* registry, | |
156 net::URLRequestContextGetter* url_request_context_getter, | |
157 const DownloadActionCallback& download_action_callback, | |
158 const GetContentCallback& get_content_callback, | |
159 const GURL& content_url, | |
160 const FilePath& drive_file_path, | |
161 const FilePath& output_file_path); | |
162 virtual ~DownloadFileOperation(); | |
163 | |
164 protected: | |
165 // UrlFetchOperationBase overrides. | |
166 virtual GURL GetURL() const OVERRIDE; | |
167 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; | |
168 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE; | |
169 | |
170 // net::URLFetcherDelegate overrides. | |
171 virtual void OnURLFetchDownloadProgress(const net::URLFetcher* source, | |
172 int64 current, int64 total) OVERRIDE; | |
173 virtual bool ShouldSendDownloadData() OVERRIDE; | |
174 virtual void OnURLFetchDownloadData( | |
175 const net::URLFetcher* source, | |
176 scoped_ptr<std::string> download_data) OVERRIDE; | |
177 | |
178 private: | |
179 const DownloadActionCallback download_action_callback_; | |
180 const GetContentCallback get_content_callback_; | |
181 const GURL content_url_; | |
182 | |
183 DISALLOW_COPY_AND_ASSIGN(DownloadFileOperation); | |
184 }; | |
185 | |
186 //=========================== DeleteResourceOperation ========================== | 127 //=========================== DeleteResourceOperation ========================== |
187 | 128 |
188 // This class performs the operation for deleting a resource. | 129 // This class performs the operation for deleting a resource. |
189 // | 130 // |
190 // In WAPI, "gd:deleted" means that the resource was put in the trash, and | 131 // In WAPI, "gd:deleted" means that the resource was put in the trash, and |
191 // "docs:removed" means its permanently gone. Since what the class does is to | 132 // "docs:removed" means its permanently gone. Since what the class does is to |
192 // put the resource into trash, we have chosen "Delete" in the name, even though | 133 // put the resource into trash, we have chosen "Delete" in the name, even though |
193 // we are preferring the term "Remove" in drive/google_api code. | 134 // we are preferring the term "Remove" in drive/google_api code. |
194 class DeleteResourceOperation : public EntryActionOperation { | 135 class DeleteResourceOperation : public EntryActionOperation { |
195 public: | 136 public: |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 | 528 |
588 // Note: This should remain the last member so it'll be destroyed and | 529 // Note: This should remain the last member so it'll be destroyed and |
589 // invalidate its weak pointers before any other members are destroyed. | 530 // invalidate its weak pointers before any other members are destroyed. |
590 base::WeakPtrFactory<ResumeUploadOperation> weak_ptr_factory_; | 531 base::WeakPtrFactory<ResumeUploadOperation> weak_ptr_factory_; |
591 DISALLOW_COPY_AND_ASSIGN(ResumeUploadOperation); | 532 DISALLOW_COPY_AND_ASSIGN(ResumeUploadOperation); |
592 }; | 533 }; |
593 | 534 |
594 } // namespace google_apis | 535 } // namespace google_apis |
595 | 536 |
596 #endif // CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_OPERATIONS_H_ | 537 #endif // CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_OPERATIONS_H_ |
OLD | NEW |