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

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

Issue 211483004: Remove some PlatformFile instances from ChromeOS Drive. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change FileStream destruction logic Created 6 years, 8 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 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 CHROME_BROWSER_CHROMEOS_DRIVE_LOCAL_FILE_READER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_LOCAL_FILE_READER_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_LOCAL_FILE_READER_H_ 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_LOCAL_FILE_READER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/platform_file.h"
12 #include "net/base/completion_callback.h" 11 #include "net/base/completion_callback.h"
12 #include "net/base/file_stream.h"
13 13
14 namespace base { 14 namespace base {
15 class FilePath; 15 class FilePath;
16 class SequencedTaskRunner; 16 class SequencedTaskRunner;
17 } // namespace base 17 } // namespace base
18 18
19 namespace net { 19 namespace net {
20 class IOBuffer; 20 class IOBuffer;
21 } // namespace 21 } // namespace net
22 22
23 namespace drive { 23 namespace drive {
24 namespace util { 24 namespace util {
25 25
26 // This is simple local file reader implementation focusing on Drive's use 26 // This is simple local file reader implementation focusing on Drive's use
27 // case. All the operations run on |sequenced_task_runner| asynchronously and 27 // case. All the operations run on |sequenced_task_runner| asynchronously and
28 // the result will be notified to the caller via |callback|s on the caller's 28 // the result will be notified to the caller via |callback|s on the caller's
29 // thread. 29 // thread.
30 class LocalFileReader { 30 class LocalFileReader {
31 public: 31 public:
(...skipping 10 matching lines...) Expand all
42 42
43 // Reads the file and copies the data into |buffer|. |buffer_length| 43 // Reads the file and copies the data into |buffer|. |buffer_length|
44 // is the length of |buffer|. 44 // is the length of |buffer|.
45 // Upon completion, |callback| will be called with the result. 45 // Upon completion, |callback| will be called with the result.
46 // |callback| must not be null. 46 // |callback| must not be null.
47 void Read(net::IOBuffer* buffer, 47 void Read(net::IOBuffer* buffer,
48 int buffer_length, 48 int buffer_length,
49 const net::CompletionCallback& callback); 49 const net::CompletionCallback& callback);
50 50
51 private: 51 private:
52 // The thin wrapper for the platform file to handle closing correctly. 52 void DidOpen(const net::CompletionCallback& callback,
53 class ScopedPlatformFile; 53 int64 offset,
54 int error);
55 void DidSeek(const net::CompletionCallback& callback,
56 int64 offset,
57 int64 error);
54 58
55 // Part of Open(). Called after the open() operation task running 59 net::FileStream file_stream_;
56 // on blocking pool.
57 void OpenAfterBlockingPoolTask(
58 const net::CompletionCallback& callback,
59 ScopedPlatformFile* result_platform_file,
60 int open_result);
61
62 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner_;
63 base::PlatformFile platform_file_;
64 60
65 // Note: This should remain the last member so it'll be destroyed and 61 // Note: This should remain the last member so it'll be destroyed and
66 // invalidate the weak pointers before any other members are destroyed. 62 // invalidate the weak pointers before any other members are destroyed.
67 base::WeakPtrFactory<LocalFileReader> weak_ptr_factory_; 63 base::WeakPtrFactory<LocalFileReader> weak_ptr_factory_;
68 DISALLOW_COPY_AND_ASSIGN(LocalFileReader); 64 DISALLOW_COPY_AND_ASSIGN(LocalFileReader);
69 }; 65 };
70 66
71 } // namespace util 67 } // namespace util
72 } // namespace drive 68 } // namespace drive
73 69
74 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_LOCAL_FILE_READER_H_ 70 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_LOCAL_FILE_READER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/file_system/truncate_operation.cc ('k') | chrome/browser/chromeos/drive/local_file_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698