| 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/platform/WebFileWriter.h" | 10 #include "third_party/WebKit/public/platform/WebFileWriter.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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); | 28 virtual void write(long long position, const WebKit::WebString& id); |
| 29 virtual void cancel(); | 29 virtual void cancel(); |
| 30 | 30 |
| 31 // DEPRECATED: see crbug/174200 | |
| 32 virtual void write(long long position, const WebKit::WebURL& blobURL); | |
| 33 | |
| 34 protected: | 31 protected: |
| 35 // This calls DidSucceed() or DidFail() based on the value of |error_code|. | 32 // This calls DidSucceed() or DidFail() based on the value of |error_code|. |
| 36 void DidFinish(base::PlatformFileError error_code); | 33 void DidFinish(base::PlatformFileError error_code); |
| 37 | 34 |
| 38 void DidWrite(int64 bytes, bool complete); | 35 void DidWrite(int64 bytes, bool complete); |
| 39 void DidSucceed(); | 36 void DidSucceed(); |
| 40 void DidFail(base::PlatformFileError error_code); | 37 void DidFail(base::PlatformFileError error_code); |
| 41 | 38 |
| 42 // Derived classes must provide these methods to asynchronously perform | 39 // Derived classes must provide these methods to asynchronously perform |
| 43 // the requested operation, and they must call the appropiate DidSomething | 40 // the requested operation, and they must call the appropiate DidSomething |
| 44 // method upon completion and as progress is made in the Write case. | 41 // method upon completion and as progress is made in the Write case. |
| 45 virtual void DoTruncate(const GURL& path, int64 offset) = 0; | 42 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; | |
| 49 virtual void DoWrite(const GURL& path, | 43 virtual void DoWrite(const GURL& path, |
| 50 const std::string& blob_id, | 44 const std::string& blob_id, |
| 51 int64 offset) = 0; | 45 int64 offset) = 0; |
| 52 virtual void DoCancel() = 0; | 46 virtual void DoCancel() = 0; |
| 53 | 47 |
| 54 private: | 48 private: |
| 55 enum OperationType { | 49 enum OperationType { |
| 56 kOperationNone, | 50 kOperationNone, |
| 57 kOperationWrite, | 51 kOperationWrite, |
| 58 kOperationTruncate | 52 kOperationTruncate |
| 59 }; | 53 }; |
| 60 | 54 |
| 61 enum CancelState { | 55 enum CancelState { |
| 62 kCancelNotInProgress, | 56 kCancelNotInProgress, |
| 63 kCancelSent, | 57 kCancelSent, |
| 64 kCancelReceivedWriteResponse, | 58 kCancelReceivedWriteResponse, |
| 65 }; | 59 }; |
| 66 | 60 |
| 67 void FinishCancel(); | 61 void FinishCancel(); |
| 68 | 62 |
| 69 GURL path_; | 63 GURL path_; |
| 70 WebKit::WebFileWriterClient* client_; | 64 WebKit::WebFileWriterClient* client_; |
| 71 OperationType operation_; | 65 OperationType operation_; |
| 72 CancelState cancel_state_; | 66 CancelState cancel_state_; |
| 73 }; | 67 }; |
| 74 | 68 |
| 75 } // namespace content | 69 } // namespace content |
| 76 | 70 |
| 77 #endif // CONTENT_CHILD_FILEAPI_WEBFILEWRITER_BASE_H_ | 71 #endif // CONTENT_CHILD_FILEAPI_WEBFILEWRITER_BASE_H_ |
| OLD | NEW |