• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_H_
6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_H_
7 
8 #include "base/memory/weak_ptr.h"
9 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info.h"
10 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_interface.h"
11 #include "chrome/browser/chromeos/file_system_provider/request_manager.h"
12 #include "webkit/browser/fileapi/async_file_util.h"
13 
14 namespace net {
15 class IOBuffer;
16 }  // namespace net
17 
18 namespace base {
19 class FilePath;
20 }  // namespace base
21 
22 namespace extensions {
23 class EventRouter;
24 }  // namespace extensions
25 
26 namespace chromeos {
27 namespace file_system_provider {
28 
29 // Provided file system implementation. Forwards requests between providers and
30 // clients.
31 class ProvidedFileSystem : public ProvidedFileSystemInterface {
32  public:
33   ProvidedFileSystem(extensions::EventRouter* event_router,
34                      const ProvidedFileSystemInfo& file_system_info);
35   virtual ~ProvidedFileSystem();
36 
37   // ProvidedFileSystemInterface overrides.
38   virtual void RequestUnmount(
39       const fileapi::AsyncFileUtil::StatusCallback& callback) OVERRIDE;
40   virtual void GetMetadata(
41       const base::FilePath& entry_path,
42       const fileapi::AsyncFileUtil::GetFileInfoCallback& callback) OVERRIDE;
43   virtual void ReadDirectory(
44       const base::FilePath& directory_path,
45       const fileapi::AsyncFileUtil::ReadDirectoryCallback& callback) OVERRIDE;
46   virtual void OpenFile(const base::FilePath& file_path,
47                         OpenFileMode mode,
48                         bool create,
49                         const OpenFileCallback& callback) OVERRIDE;
50   virtual void CloseFile(
51       int file_handle,
52       const fileapi::AsyncFileUtil::StatusCallback& callback) OVERRIDE;
53   virtual void ReadFile(int file_handle,
54                         net::IOBuffer* buffer,
55                         int64 offset,
56                         int length,
57                         const ReadChunkReceivedCallback& callback) OVERRIDE;
58   virtual const ProvidedFileSystemInfo& GetFileSystemInfo() const OVERRIDE;
59   virtual RequestManager* GetRequestManager() OVERRIDE;
60   virtual base::WeakPtr<ProvidedFileSystemInterface> GetWeakPtr() OVERRIDE;
61 
62  private:
63   extensions::EventRouter* event_router_;
64   RequestManager request_manager_;
65   ProvidedFileSystemInfo file_system_info_;
66 
67   base::WeakPtrFactory<ProvidedFileSystemInterface> weak_ptr_factory_;
68   DISALLOW_COPY_AND_ASSIGN(ProvidedFileSystem);
69 };
70 
71 }  // namespace file_system_provider
72 }  // namespace chromeos
73 
74 #endif  // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_H_
75