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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/fake_provided_file_system.h

Issue 288113004: [fsp] Add FileStreamReader for the reading operation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed tests. Created 6 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_FILE_SYSTEM_PROVIDER_FAKE_PROVIDED_FILE_SYSTEM_H _ 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FAKE_PROVIDED_FILE_SYSTEM_H _
6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FAKE_PROVIDED_FILE_SYSTEM_H _ 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FAKE_PROVIDED_FILE_SYSTEM_H _
7 7
8 #include <set> 8 #include <map>
9 9
10 #include "base/memory/weak_ptr.h"
10 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info .h" 11 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info .h"
11 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte rface.h" 12 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte rface.h"
12 13
13 namespace net { 14 namespace net {
14 class IOBuffer; 15 class IOBuffer;
15 } // namespace net 16 } // namespace net
16 17
17 namespace extensions { 18 namespace extensions {
18 class EventRouter; 19 class EventRouter;
19 } // namespace extensions 20 } // namespace extensions
20 21
21 namespace chromeos { 22 namespace chromeos {
22 namespace file_system_provider { 23 namespace file_system_provider {
23 24
24 class RequestManager; 25 class RequestManager;
25 26
27 extern const char kFakeFileName[];
28 extern const char kFakeFilePath[];
29 extern const char kFakeFileText[];
30 extern const size_t kFakeFileSize;
31
26 // Fake provided file system implementation. Does not communicate with target 32 // Fake provided file system implementation. Does not communicate with target
27 // extensions. Used for unit tests. 33 // extensions. Used for unit tests.
28 class FakeProvidedFileSystem : public ProvidedFileSystemInterface { 34 class FakeProvidedFileSystem : public ProvidedFileSystemInterface {
29 public: 35 public:
30 explicit FakeProvidedFileSystem( 36 explicit FakeProvidedFileSystem(
31 const ProvidedFileSystemInfo& file_system_info); 37 const ProvidedFileSystemInfo& file_system_info);
32 virtual ~FakeProvidedFileSystem(); 38 virtual ~FakeProvidedFileSystem();
33 39
34 // ProvidedFileSystemInterface overrides. 40 // ProvidedFileSystemInterface overrides.
35 virtual void RequestUnmount( 41 virtual void RequestUnmount(
(...skipping 11 matching lines...) Expand all
47 virtual void CloseFile( 53 virtual void CloseFile(
48 int file_handle, 54 int file_handle,
49 const fileapi::AsyncFileUtil::StatusCallback& callback) OVERRIDE; 55 const fileapi::AsyncFileUtil::StatusCallback& callback) OVERRIDE;
50 virtual void ReadFile(int file_handle, 56 virtual void ReadFile(int file_handle,
51 net::IOBuffer* buffer, 57 net::IOBuffer* buffer,
52 int64 offset, 58 int64 offset,
53 int length, 59 int length,
54 const ReadChunkReceivedCallback& callback) OVERRIDE; 60 const ReadChunkReceivedCallback& callback) OVERRIDE;
55 virtual const ProvidedFileSystemInfo& GetFileSystemInfo() const OVERRIDE; 61 virtual const ProvidedFileSystemInfo& GetFileSystemInfo() const OVERRIDE;
56 virtual RequestManager* GetRequestManager() OVERRIDE; 62 virtual RequestManager* GetRequestManager() OVERRIDE;
63 virtual base::WeakPtr<ProvidedFileSystemInterface> GetWeakPtr() OVERRIDE;
57 64
58 // Factory callback, to be used in Service::SetFileSystemFactory(). The 65 // Factory callback, to be used in Service::SetFileSystemFactory(). The
59 // |event_router| argument can be NULL. 66 // |event_router| argument can be NULL.
60 static ProvidedFileSystemInterface* Create( 67 static ProvidedFileSystemInterface* Create(
61 extensions::EventRouter* event_router, 68 extensions::EventRouter* event_router,
62 const ProvidedFileSystemInfo& file_system_info); 69 const ProvidedFileSystemInfo& file_system_info);
63 70
64 private: 71 private:
72 typedef std::map<int, base::FilePath> OpenedFilesMap;
73
65 ProvidedFileSystemInfo file_system_info_; 74 ProvidedFileSystemInfo file_system_info_;
66 std::set<int> opened_files_; 75 OpenedFilesMap opened_files_;
67 int last_file_handle_; 76 int last_file_handle_;
68 77
78 base::WeakPtrFactory<ProvidedFileSystemInterface> weak_ptr_factory_;
69 DISALLOW_COPY_AND_ASSIGN(FakeProvidedFileSystem); 79 DISALLOW_COPY_AND_ASSIGN(FakeProvidedFileSystem);
70 }; 80 };
71 81
72 } // namespace file_system_provider 82 } // namespace file_system_provider
73 } // namespace chromeos 83 } // namespace chromeos
74 84
75 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FAKE_PROVIDED_FILE_SYSTE M_H_ 85 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FAKE_PROVIDED_FILE_SYSTE M_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698