| 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 WEBKIT_FILEAPI_WEBFILEWRITER_BASE_H_ | 5 #ifndef WEBKIT_FILEAPI_WEBFILEWRITER_BASE_H_ |
| 6 #define WEBKIT_FILEAPI_WEBFILEWRITER_BASE_H_ | 6 #define WEBKIT_FILEAPI_WEBFILEWRITER_BASE_H_ |
| 7 | 7 |
| 8 #include "base/platform_file.h" | 8 #include "base/platform_file.h" |
| 9 #include "googleurl/src/gurl.h" | 9 #include "googleurl/src/gurl.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileWriter.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileWriter.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 WebFileWriterBase( | 23 WebFileWriterBase( |
| 24 const GURL& path, WebKit::WebFileWriterClient* client); | 24 const GURL& path, WebKit::WebFileWriterClient* client); |
| 25 virtual ~WebFileWriterBase(); | 25 virtual ~WebFileWriterBase(); |
| 26 | 26 |
| 27 // WebFileWriter implementation | 27 // WebFileWriter implementation |
| 28 virtual void truncate(long long length); | 28 virtual void truncate(long long length); |
| 29 virtual void write(long long position, const WebKit::WebURL& blobURL); | 29 virtual void write(long long position, const WebKit::WebURL& blobURL); |
| 30 virtual void cancel(); | 30 virtual void cancel(); |
| 31 | 31 |
| 32 protected: | 32 protected: |
| 33 // This calls DidSucceed() or DidFail() based on the value of |error_code|. |
| 34 void DidFinish(base::PlatformFileError error_code); |
| 35 |
| 36 void DidWrite(int64 bytes, bool complete); |
| 37 void DidSucceed(); |
| 38 void DidFail(base::PlatformFileError error_code); |
| 39 |
| 33 // Derived classes must provide these methods to asynchronously perform | 40 // Derived classes must provide these methods to asynchronously perform |
| 34 // the requested operation, and they must call the appropiate DidSomething | 41 // the requested operation, and they must call the appropiate DidSomething |
| 35 // method upon completion and as progress is made in the Write case. | 42 // method upon completion and as progress is made in the Write case. |
| 36 virtual void DoTruncate(const GURL& path, int64 offset) = 0; | 43 virtual void DoTruncate(const GURL& path, int64 offset) = 0; |
| 37 virtual void DoWrite(const GURL& path, const GURL& blob_url, | 44 virtual void DoWrite(const GURL& path, const GURL& blob_url, |
| 38 int64 offset) = 0; | 45 int64 offset) = 0; |
| 39 virtual void DoCancel() = 0; | 46 virtual void DoCancel() = 0; |
| 40 | 47 |
| 41 void DidSucceed(); | |
| 42 void DidFail(base::PlatformFileError error_code); | |
| 43 void DidWrite(int64 bytes, bool complete); | |
| 44 | |
| 45 private: | 48 private: |
| 46 enum OperationType { | 49 enum OperationType { |
| 47 kOperationNone, | 50 kOperationNone, |
| 48 kOperationWrite, | 51 kOperationWrite, |
| 49 kOperationTruncate | 52 kOperationTruncate |
| 50 }; | 53 }; |
| 51 | 54 |
| 52 enum CancelState { | 55 enum CancelState { |
| 53 kCancelNotInProgress, | 56 kCancelNotInProgress, |
| 54 kCancelSent, | 57 kCancelSent, |
| 55 kCancelReceivedWriteResponse, | 58 kCancelReceivedWriteResponse, |
| 56 }; | 59 }; |
| 57 | 60 |
| 58 void FinishCancel(); | 61 void FinishCancel(); |
| 59 | 62 |
| 60 GURL path_; | 63 GURL path_; |
| 61 WebKit::WebFileWriterClient* client_; | 64 WebKit::WebFileWriterClient* client_; |
| 62 OperationType operation_; | 65 OperationType operation_; |
| 63 CancelState cancel_state_; | 66 CancelState cancel_state_; |
| 64 }; | 67 }; |
| 65 | 68 |
| 66 } // namespace fileapi | 69 } // namespace fileapi |
| 67 | 70 |
| 68 #endif // WEBKIT_FILEAPI_WEBFILEWRITER_BASE_H_ | 71 #endif // WEBKIT_FILEAPI_WEBFILEWRITER_BASE_H_ |
| OLD | NEW |