Experimental push messaging api reference docs.
[chromium-blink-merge.git] / webkit / fileapi / webfilewriter_base.h
blob61eec5ff4416f33911aa3a07da6e84d06ef7c826
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
3 // found in the LICENSE file.
5 #ifndef WEBKIT_FILEAPI_WEBFILEWRITER_BASE_H_
6 #define WEBKIT_FILEAPI_WEBFILEWRITER_BASE_H_
8 #include "base/platform_file.h"
9 #include "googleurl/src/gurl.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileWriter.h"
11 #include "webkit/fileapi/fileapi_export.h"
13 namespace WebKit {
14 class WebFileWriterClient;
15 class WebURL;
18 namespace fileapi {
20 class FILEAPI_EXPORT WebFileWriterBase
21 : public NON_EXPORTED_BASE(WebKit::WebFileWriter) {
22 public:
23 WebFileWriterBase(
24 const GURL& path, WebKit::WebFileWriterClient* client);
25 virtual ~WebFileWriterBase();
27 // WebFileWriter implementation
28 virtual void truncate(long long length);
29 virtual void write(long long position, const WebKit::WebURL& blobURL);
30 virtual void cancel();
32 protected:
33 // Derived classes must provide these methods to asynchronously perform
34 // the requested operation, and they must call the appropiate DidSomething
35 // method upon completion and as progress is made in the Write case.
36 virtual void DoTruncate(const GURL& path, int64 offset) = 0;
37 virtual void DoWrite(const GURL& path, const GURL& blob_url,
38 int64 offset) = 0;
39 virtual void DoCancel() = 0;
41 void DidSucceed();
42 void DidFail(base::PlatformFileError error_code);
43 void DidWrite(int64 bytes, bool complete);
45 private:
46 enum OperationType {
47 kOperationNone,
48 kOperationWrite,
49 kOperationTruncate
52 enum CancelState {
53 kCancelNotInProgress,
54 kCancelSent,
55 kCancelReceivedWriteResponse,
58 void FinishCancel();
60 GURL path_;
61 WebKit::WebFileWriterClient* client_;
62 OperationType operation_;
63 CancelState cancel_state_;
66 } // namespace fileapi
68 #endif // WEBKIT_FILEAPI_WEBFILEWRITER_BASE_H_