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

Side by Side Diff: chrome/browser/chromeos/drive/webkit_file_stream_reader_impl.h

Issue 148913005: Create fileapi/ subdirectory under c/b/cros/drive. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_WEBKIT_FILE_STREAM_READER_IMPL_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_WEBKIT_FILE_STREAM_READER_IMPL_H_
7
8 #include "base/basictypes.h"
9 #include "base/files/file_path.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/time/time.h"
14 #include "chrome/browser/chromeos/drive/drive_file_stream_reader.h"
15 #include "net/base/completion_callback.h"
16 #include "webkit/browser/blob/file_stream_reader.h"
17
18 namespace base {
19 class SequencedTaskRunner;
20 } // namespace base
21
22 namespace drive {
23
24 class ResourceEntry;
25
26 namespace internal {
27
28 // The implementation of webkit_blob::FileStreamReader for drive file system.
29 // webkit_blob::FileStreamReader does not provide a way for explicit
30 // initialization, hence the initialization of this class will be done lazily.
31 // Note that when crbug.com/225339 is resolved, this class will be also
32 // initialized explicitly.
33 class WebkitFileStreamReaderImpl : public webkit_blob::FileStreamReader {
34 public:
35 WebkitFileStreamReaderImpl(
36 const DriveFileStreamReader::FileSystemGetter& file_system_getter,
37 base::SequencedTaskRunner* file_task_runner,
38 const base::FilePath& drive_file_path,
39 int64 offset,
40 const base::Time& expected_modification_time);
41 virtual ~WebkitFileStreamReaderImpl();
42
43 // webkit_blob::FileStreamReader override.
44 virtual int Read(net::IOBuffer* buffer,
45 int buffer_length,
46 const net::CompletionCallback& callback) OVERRIDE;
47 virtual int64 GetLength(const net::Int64CompletionCallback& callback)
48 OVERRIDE;
49
50 private:
51 // Called upon the initialization completion of |stream_reader_|.
52 // Processes the result of the initialization with checking last
53 // modified time, and calls |callback| with net::Error code as its result.
54 void OnStreamReaderInitialized(
55 const net::CompletionCallback& callback,
56 int error,
57 scoped_ptr<ResourceEntry> entry);
58
59 // Part of Read(). Called after all the initialization process is completed.
60 void ReadAfterStreamReaderInitialized(
61 scoped_refptr<net::IOBuffer> buffer,
62 int buffer_length,
63 const net::CompletionCallback& callback,
64 int initialization_result);
65
66 // Part of GetLength(). Called after all the initialization process is
67 // completed.
68 void GetLengthAfterStreamReaderInitialized(
69 const net::Int64CompletionCallback& callback,
70 int initialization_result);
71
72 scoped_ptr<DriveFileStreamReader> stream_reader_;
73 const base::FilePath drive_file_path_;
74 const int64 offset_;
75 const base::Time expected_modification_time_;
76
77 // This is available only after initialize is done.
78 int64 file_size_;
79
80 // This should remain the last member so it'll be destroyed first and
81 // invalidate its weak pointers before other members are destroyed.
82 base::WeakPtrFactory<WebkitFileStreamReaderImpl> weak_ptr_factory_;
83 DISALLOW_COPY_AND_ASSIGN(WebkitFileStreamReaderImpl);
84 };
85
86 } // namespace internal
87 } // namespace drive
88
89 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_WEBKIT_FILE_STREAM_READER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698