Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Side by Side Diff: chrome/browser/chromeos/fileapi/remote_file_stream_writer.h

Issue 17644006: Move files under webkit/browser/fileapi/... to chrome/browser/chromeos/fileapi/... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comments. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_BROWSER_CHROMEOS_FILEAPI_REMOTE_FILE_STREAM_WRITER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_FILEAPI_REMOTE_FILE_STREAM_WRITER_H_
6 #define WEBKIT_BROWSER_CHROMEOS_FILEAPI_REMOTE_FILE_STREAM_WRITER_H_ 6 #define CHROME_BROWSER_CHROMEOS_FILEAPI_REMOTE_FILE_STREAM_WRITER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/platform_file.h" 12 #include "base/platform_file.h"
13 #include "webkit/browser/fileapi/file_stream_writer.h" 13 #include "webkit/browser/fileapi/file_stream_writer.h"
14 #include "webkit/browser/fileapi/file_system_context.h" 14 #include "webkit/browser/fileapi/file_system_context.h"
15 #include "webkit/browser/fileapi/file_system_url.h" 15 #include "webkit/browser/fileapi/file_system_url.h"
16 16
17 namespace fileapi {
18 class RemoteFileSystemProxyInterface;
19 }
20
17 namespace net { 21 namespace net {
18 class IOBuffer; 22 class IOBuffer;
19 } 23 }
20 24
21 namespace webkit_blob { 25 namespace webkit_blob {
22 class ShareableFileReference; 26 class ShareableFileReference;
23 } 27 }
24 28
25 namespace fileapi { 29 namespace chromeos {
26
27 class RemoteFileSystemProxyInterface;
28 30
29 // FileStreamWriter interface for writing to a file on remote file system. 31 // FileStreamWriter interface for writing to a file on remote file system.
30 class RemoteFileStreamWriter : public fileapi::FileStreamWriter { 32 class RemoteFileStreamWriter : public fileapi::FileStreamWriter {
31 public: 33 public:
32 // Creates a writer for a file on |remote_filesystem| with path url |url| 34 // Creates a writer for a file on |remote_filesystem| with path url |url|
33 // (like "filesystem:chrome-extension://id/external/drive/...") that 35 // (like "filesystem:chrome-extension://id/external/drive/...") that
34 // starts writing from |offset|. When invalid parameters are set, the first 36 // starts writing from |offset|. When invalid parameters are set, the first
35 // call to Write() method fails. 37 // call to Write() method fails.
36 // Uses |local_task_runner| for local file operations. 38 // Uses |local_task_runner| for local file operations.
37 RemoteFileStreamWriter( 39 RemoteFileStreamWriter(
38 const scoped_refptr<RemoteFileSystemProxyInterface>& remote_filesystem, 40 const scoped_refptr<fileapi::RemoteFileSystemProxyInterface>&
39 const FileSystemURL& url, 41 remote_filesystem,
42 const fileapi::FileSystemURL& url,
40 int64 offset, 43 int64 offset,
41 base::TaskRunner* local_task_runner); 44 base::TaskRunner* local_task_runner);
42 virtual ~RemoteFileStreamWriter(); 45 virtual ~RemoteFileStreamWriter();
43 46
44 // FileWriter override. 47 // FileWriter override.
45 virtual int Write(net::IOBuffer* buf, int buf_len, 48 virtual int Write(net::IOBuffer* buf, int buf_len,
46 const net::CompletionCallback& callback) OVERRIDE; 49 const net::CompletionCallback& callback) OVERRIDE;
47 virtual int Cancel(const net::CompletionCallback& callback) OVERRIDE; 50 virtual int Cancel(const net::CompletionCallback& callback) OVERRIDE;
48 virtual int Flush(const net::CompletionCallback& callback) OVERRIDE; 51 virtual int Flush(const net::CompletionCallback& callback) OVERRIDE;
49 52
50 private: 53 private:
51 // Callback function to do the continuation of the work of the first Write() 54 // Callback function to do the continuation of the work of the first Write()
52 // call, which tries to open the local copy of the file before writing. 55 // call, which tries to open the local copy of the file before writing.
53 void OnFileOpened( 56 void OnFileOpened(
54 net::IOBuffer* buf, 57 net::IOBuffer* buf,
55 int buf_len, 58 int buf_len,
56 const net::CompletionCallback& callback, 59 const net::CompletionCallback& callback,
57 base::PlatformFileError open_result, 60 base::PlatformFileError open_result,
58 const base::FilePath& local_path, 61 const base::FilePath& local_path,
59 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref); 62 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref);
60 // Calls |pending_cancel_callback_|, assuming it is non-null. 63 // Calls |pending_cancel_callback_|, assuming it is non-null.
61 void InvokePendingCancelCallback(int result); 64 void InvokePendingCancelCallback(int result);
62 65
63 scoped_refptr<RemoteFileSystemProxyInterface> remote_filesystem_; 66 scoped_refptr<fileapi::RemoteFileSystemProxyInterface> remote_filesystem_;
64 scoped_refptr<base::TaskRunner> local_task_runner_; 67 scoped_refptr<base::TaskRunner> local_task_runner_;
65 const FileSystemURL url_; 68 const fileapi::FileSystemURL url_;
66 const int64 initial_offset_; 69 const int64 initial_offset_;
67 scoped_ptr<fileapi::FileStreamWriter> local_file_writer_; 70 scoped_ptr<fileapi::FileStreamWriter> local_file_writer_;
68 scoped_refptr<webkit_blob::ShareableFileReference> file_ref_; 71 scoped_refptr<webkit_blob::ShareableFileReference> file_ref_;
69 bool has_pending_create_snapshot_; 72 bool has_pending_create_snapshot_;
70 net::CompletionCallback pending_cancel_callback_; 73 net::CompletionCallback pending_cancel_callback_;
71 74
72 base::WeakPtrFactory<RemoteFileStreamWriter> weak_factory_; 75 base::WeakPtrFactory<RemoteFileStreamWriter> weak_factory_;
73 76
74 DISALLOW_COPY_AND_ASSIGN(RemoteFileStreamWriter); 77 DISALLOW_COPY_AND_ASSIGN(RemoteFileStreamWriter);
75 }; 78 };
76 79
77 } // namespace fileapi 80 } // namespace chromeos
78 81
79 #endif // WEBKIT_BROWSER_CHROMEOS_FILEAPI_REMOTE_FILE_STREAM_WRITER_H_ 82 #endif // CHROME_BROWSER_CHROMEOS_FILEAPI_REMOTE_FILE_STREAM_WRITER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698