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.
5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_H_
6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_H_
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 "storage/browser/fileapi/async_file_util.h"
24 namespace extensions {
26 } // namespace extensions
29 namespace file_system_provider {
31 class NotificationManagerInterface;
33 // Provided file system implementation. Forwards requests between providers and
35 class ProvidedFileSystem : public ProvidedFileSystemInterface {
37 ProvidedFileSystem(Profile* profile,
38 const ProvidedFileSystemInfo& file_system_info);
39 virtual ~ProvidedFileSystem();
41 // ProvidedFileSystemInterface overrides.
42 virtual AbortCallback RequestUnmount(
43 const storage::AsyncFileUtil::StatusCallback& callback) OVERRIDE;
44 virtual AbortCallback GetMetadata(
45 const base::FilePath& entry_path,
46 MetadataFieldMask fields,
47 const GetMetadataCallback& callback) OVERRIDE;
48 virtual AbortCallback ReadDirectory(
49 const base::FilePath& directory_path,
50 const storage::AsyncFileUtil::ReadDirectoryCallback& callback) OVERRIDE;
51 virtual AbortCallback OpenFile(const base::FilePath& file_path,
53 const OpenFileCallback& callback) OVERRIDE;
54 virtual AbortCallback CloseFile(
56 const storage::AsyncFileUtil::StatusCallback& callback) OVERRIDE;
57 virtual AbortCallback ReadFile(
59 net::IOBuffer* buffer,
62 const ReadChunkReceivedCallback& callback) OVERRIDE;
63 virtual AbortCallback CreateDirectory(
64 const base::FilePath& directory_path,
66 const storage::AsyncFileUtil::StatusCallback& callback) OVERRIDE;
67 virtual AbortCallback DeleteEntry(
68 const base::FilePath& entry_path,
70 const storage::AsyncFileUtil::StatusCallback& callback) OVERRIDE;
71 virtual AbortCallback CreateFile(
72 const base::FilePath& file_path,
73 const storage::AsyncFileUtil::StatusCallback& callback) OVERRIDE;
74 virtual AbortCallback CopyEntry(
75 const base::FilePath& source_path,
76 const base::FilePath& target_path,
77 const storage::AsyncFileUtil::StatusCallback& callback) OVERRIDE;
78 virtual AbortCallback MoveEntry(
79 const base::FilePath& source_path,
80 const base::FilePath& target_path,
81 const storage::AsyncFileUtil::StatusCallback& callback) OVERRIDE;
82 virtual AbortCallback Truncate(
83 const base::FilePath& file_path,
85 const storage::AsyncFileUtil::StatusCallback& callback) OVERRIDE;
86 virtual AbortCallback WriteFile(
88 net::IOBuffer* buffer,
91 const storage::AsyncFileUtil::StatusCallback& callback) OVERRIDE;
92 virtual const ProvidedFileSystemInfo& GetFileSystemInfo() const OVERRIDE;
93 virtual RequestManager* GetRequestManager() OVERRIDE;
94 virtual base::WeakPtr<ProvidedFileSystemInterface> GetWeakPtr() OVERRIDE;
97 // Aborts an operation executed with a request id equal to
98 // |operation_request_id|. The request is removed immediately on the C++ side
99 // despite being handled by the providing extension or not.
100 void Abort(int operation_request_id,
101 const storage::AsyncFileUtil::StatusCallback& callback);
103 Profile* profile_; // Not owned.
104 extensions::EventRouter* event_router_; // Not owned. May be NULL.
105 ProvidedFileSystemInfo file_system_info_;
106 scoped_ptr<NotificationManagerInterface> notification_manager_;
107 RequestManager request_manager_;
109 base::WeakPtrFactory<ProvidedFileSystem> weak_ptr_factory_;
110 DISALLOW_COPY_AND_ASSIGN(ProvidedFileSystem);
113 } // namespace file_system_provider
114 } // namespace chromeos
116 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_H_