file_manager: Remove fileBrowserPrivate.viewFiles()
[chromium-blink-merge.git] / content / child / fileapi / webfilesystem_impl.h
blobd439158a6e2ed803baf497e562d126501994fcb7
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.
5 #ifndef CONTENT_CHILD_FILEAPI_WEBFILESYSTEM_IMPL_H_
6 #define CONTENT_CHILD_FILEAPI_WEBFILESYSTEM_IMPL_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/id_map.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/threading/non_thread_safe.h"
13 #include "third_party/WebKit/public/platform/WebFileSystem.h"
14 #include "webkit/child/worker_task_runner.h"
16 namespace base {
17 class MessageLoopProxy;
20 namespace WebKit {
21 class WebURL;
22 class WebFileWriter;
23 class WebFileWriterClient;
26 namespace content {
28 class WebFileSystemImpl
29 : public WebKit::WebFileSystem,
30 public webkit_glue::WorkerTaskRunner::Observer,
31 public base::NonThreadSafe {
32 public:
33 // Returns thread-specific instance. If non-null |main_thread_loop|
34 // is given and no thread-specific instance has been created it may
35 // create a new instance.
36 static WebFileSystemImpl* ThreadSpecificInstance(
37 base::MessageLoopProxy* main_thread_loop);
39 // Deletes thread-specific instance (if exists). For workers it deletes
40 // itself in OnWorkerRunLoopStopped(), but for an instance created on the
41 // main thread this method must be called.
42 static void DeleteThreadSpecificInstance();
44 explicit WebFileSystemImpl(base::MessageLoopProxy* main_thread_loop);
45 virtual ~WebFileSystemImpl();
47 // webkit_glue::WorkerTaskRunner::Observer implementation.
48 virtual void OnWorkerRunLoopStopped() OVERRIDE;
50 // WebFileSystem implementation.
51 virtual void openFileSystem(
52 const WebKit::WebURL& storage_partition,
53 const WebKit::WebFileSystemType type,
54 bool create,
55 WebKit::WebFileSystemCallbacks*);
56 virtual void deleteFileSystem(
57 const WebKit::WebURL& storage_partition,
58 const WebKit::WebFileSystemType type,
59 WebKit::WebFileSystemCallbacks*);
60 virtual void move(
61 const WebKit::WebURL& src_path,
62 const WebKit::WebURL& dest_path,
63 WebKit::WebFileSystemCallbacks*) OVERRIDE;
64 virtual void copy(
65 const WebKit::WebURL& src_path,
66 const WebKit::WebURL& dest_path,
67 WebKit::WebFileSystemCallbacks*) OVERRIDE;
68 virtual void remove(
69 const WebKit::WebURL& path,
70 WebKit::WebFileSystemCallbacks*) OVERRIDE;
71 virtual void removeRecursively(
72 const WebKit::WebURL& path,
73 WebKit::WebFileSystemCallbacks*) OVERRIDE;
74 virtual void readMetadata(
75 const WebKit::WebURL& path,
76 WebKit::WebFileSystemCallbacks*) OVERRIDE;
77 virtual void createFile(
78 const WebKit::WebURL& path,
79 bool exclusive,
80 WebKit::WebFileSystemCallbacks*) OVERRIDE;
81 virtual void createDirectory(
82 const WebKit::WebURL& path,
83 bool exclusive,
84 WebKit::WebFileSystemCallbacks*) OVERRIDE;
85 virtual void fileExists(
86 const WebKit::WebURL& path,
87 WebKit::WebFileSystemCallbacks*) OVERRIDE;
88 virtual void directoryExists(
89 const WebKit::WebURL& path,
90 WebKit::WebFileSystemCallbacks*) OVERRIDE;
91 virtual void readDirectory(
92 const WebKit::WebURL& path,
93 WebKit::WebFileSystemCallbacks*) OVERRIDE;
94 virtual WebKit::WebFileWriter* createFileWriter(
95 const WebKit::WebURL& path, WebKit::WebFileWriterClient*) OVERRIDE;
96 virtual void createFileWriter(
97 const WebKit::WebURL& path,
98 WebKit::WebFileWriterClient*,
99 WebKit::WebFileSystemCallbacks*) OVERRIDE;
100 virtual void createSnapshotFileAndReadMetadata(
101 const WebKit::WebURL& path,
102 WebKit::WebFileSystemCallbacks*);
104 int RegisterCallbacks(WebKit::WebFileSystemCallbacks* callbacks);
105 WebKit::WebFileSystemCallbacks* GetAndUnregisterCallbacks(
106 int callbacks_id);
108 private:
109 scoped_refptr<base::MessageLoopProxy> main_thread_loop_;
110 IDMap<WebKit::WebFileSystemCallbacks> callbacks_;
112 DISALLOW_COPY_AND_ASSIGN(WebFileSystemImpl);
115 } // namespace content
117 #endif // CONTENT_CHILD_FILEAPI_WEBFILESYSTEM_IMPL_H_