| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CONTENT_CHILD_FILEAPI_WEBFILEWRITER_BASE_H_ | 5 #ifndef CONTENT_CHILD_FILEAPI_WEBFILEWRITER_BASE_H_ |
| 6 #define CONTENT_CHILD_FILEAPI_WEBFILEWRITER_BASE_H_ | 6 #define CONTENT_CHILD_FILEAPI_WEBFILEWRITER_BASE_H_ |
| 7 | 7 |
| 8 #include "base/platform_file.h" | 8 #include "base/platform_file.h" |
| 9 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
| 10 #include "third_party/WebKit/public/web/WebFileWriter.h" | 10 #include "third_party/WebKit/public/web/WebFileWriter.h" |
| 11 #include "url/gurl.h" | 11 #include "url/gurl.h" |
| 12 | 12 |
| 13 namespace WebKit { | 13 namespace WebKit { |
| 14 class WebFileWriterClient; | 14 class WebFileWriterClient; |
| 15 class WebURL; | 15 class WebURL; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 | 19 |
| 20 class CONTENT_EXPORT WebFileWriterBase | 20 class CONTENT_EXPORT WebFileWriterBase |
| 21 : public NON_EXPORTED_BASE(WebKit::WebFileWriter) { | 21 : public NON_EXPORTED_BASE(WebKit::WebFileWriter) { |
| 22 public: | 22 public: |
| 23 WebFileWriterBase(const GURL& path, WebKit::WebFileWriterClient* client); | 23 WebFileWriterBase(const GURL& path, WebKit::WebFileWriterClient* client); |
| 24 virtual ~WebFileWriterBase(); | 24 virtual ~WebFileWriterBase(); |
| 25 | 25 |
| 26 // WebFileWriter implementation | 26 // WebFileWriter implementation |
| 27 virtual void truncate(long long length); | 27 virtual void truncate(long long length); |
| 28 virtual void write(long long position, const WebKit::WebString& id); |
| 29 virtual void cancel(); |
| 30 |
| 31 // DEPRECATED: see crbug/174200 |
| 28 virtual void write(long long position, const WebKit::WebURL& blobURL); | 32 virtual void write(long long position, const WebKit::WebURL& blobURL); |
| 29 virtual void cancel(); | |
| 30 | 33 |
| 31 protected: | 34 protected: |
| 32 // This calls DidSucceed() or DidFail() based on the value of |error_code|. | 35 // This calls DidSucceed() or DidFail() based on the value of |error_code|. |
| 33 void DidFinish(base::PlatformFileError error_code); | 36 void DidFinish(base::PlatformFileError error_code); |
| 34 | 37 |
| 35 void DidWrite(int64 bytes, bool complete); | 38 void DidWrite(int64 bytes, bool complete); |
| 36 void DidSucceed(); | 39 void DidSucceed(); |
| 37 void DidFail(base::PlatformFileError error_code); | 40 void DidFail(base::PlatformFileError error_code); |
| 38 | 41 |
| 39 // Derived classes must provide these methods to asynchronously perform | 42 // Derived classes must provide these methods to asynchronously perform |
| 40 // the requested operation, and they must call the appropiate DidSomething | 43 // the requested operation, and they must call the appropiate DidSomething |
| 41 // method upon completion and as progress is made in the Write case. | 44 // method upon completion and as progress is made in the Write case. |
| 42 virtual void DoTruncate(const GURL& path, int64 offset) = 0; | 45 virtual void DoTruncate(const GURL& path, int64 offset) = 0; |
| 46 virtual void DoWriteDeprecated(const GURL& path, |
| 47 const GURL& blob_url, |
| 48 int64 offset) = 0; |
| 43 virtual void DoWrite(const GURL& path, | 49 virtual void DoWrite(const GURL& path, |
| 44 const GURL& blob_url, | 50 const std::string& blob_id, |
| 45 int64 offset) = 0; | 51 int64 offset) = 0; |
| 46 virtual void DoCancel() = 0; | 52 virtual void DoCancel() = 0; |
| 47 | 53 |
| 48 private: | 54 private: |
| 49 enum OperationType { | 55 enum OperationType { |
| 50 kOperationNone, | 56 kOperationNone, |
| 51 kOperationWrite, | 57 kOperationWrite, |
| 52 kOperationTruncate | 58 kOperationTruncate |
| 53 }; | 59 }; |
| 54 | 60 |
| 55 enum CancelState { | 61 enum CancelState { |
| 56 kCancelNotInProgress, | 62 kCancelNotInProgress, |
| 57 kCancelSent, | 63 kCancelSent, |
| 58 kCancelReceivedWriteResponse, | 64 kCancelReceivedWriteResponse, |
| 59 }; | 65 }; |
| 60 | 66 |
| 61 void FinishCancel(); | 67 void FinishCancel(); |
| 62 | 68 |
| 63 GURL path_; | 69 GURL path_; |
| 64 WebKit::WebFileWriterClient* client_; | 70 WebKit::WebFileWriterClient* client_; |
| 65 OperationType operation_; | 71 OperationType operation_; |
| 66 CancelState cancel_state_; | 72 CancelState cancel_state_; |
| 67 }; | 73 }; |
| 68 | 74 |
| 69 } // namespace content | 75 } // namespace content |
| 70 | 76 |
| 71 #endif // CONTENT_CHILD_FILEAPI_WEBFILEWRITER_BASE_H_ | 77 #endif // CONTENT_CHILD_FILEAPI_WEBFILEWRITER_BASE_H_ |
| OLD | NEW |