Removing uses of X11 native key events.
[chromium-blink-merge.git] / content / child / fileapi / webfilesystem_impl.h
blob3be74634b6429f9f2ba4b46c41a1990a59f7b455
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 <map>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/threading/non_thread_safe.h"
14 #include "content/child/worker_task_runner.h"
15 #include "third_party/WebKit/public/platform/WebFileSystem.h"
17 namespace base {
18 class MessageLoopProxy;
19 class WaitableEvent;
22 namespace blink {
23 class WebURL;
24 class WebFileWriter;
25 class WebFileWriterClient;
28 namespace content {
30 class WebFileSystemImpl : public blink::WebFileSystem,
31 public WorkerTaskRunner::Observer,
32 public base::NonThreadSafe {
33 public:
34 class WaitableCallbackResults;
36 // Returns thread-specific instance. If non-null |main_thread_loop|
37 // is given and no thread-specific instance has been created it may
38 // create a new instance.
39 static WebFileSystemImpl* ThreadSpecificInstance(
40 base::MessageLoopProxy* main_thread_loop);
42 // Deletes thread-specific instance (if exists). For workers it deletes
43 // itself in OnWorkerRunLoopStopped(), but for an instance created on the
44 // main thread this method must be called.
45 static void DeleteThreadSpecificInstance();
47 explicit WebFileSystemImpl(base::MessageLoopProxy* main_thread_loop);
48 virtual ~WebFileSystemImpl();
50 // WorkerTaskRunner::Observer implementation.
51 virtual void OnWorkerRunLoopStopped() OVERRIDE;
53 // WebFileSystem implementation.
54 virtual void openFileSystem(
55 const blink::WebURL& storage_partition,
56 const blink::WebFileSystemType type,
57 blink::WebFileSystemCallbacks);
58 virtual void resolveURL(
59 const blink::WebURL& filesystem_url,
60 blink::WebFileSystemCallbacks) OVERRIDE;
61 virtual void deleteFileSystem(
62 const blink::WebURL& storage_partition,
63 const blink::WebFileSystemType type,
64 blink::WebFileSystemCallbacks);
65 virtual void move(
66 const blink::WebURL& src_path,
67 const blink::WebURL& dest_path,
68 blink::WebFileSystemCallbacks) OVERRIDE;
69 virtual void copy(
70 const blink::WebURL& src_path,
71 const blink::WebURL& dest_path,
72 blink::WebFileSystemCallbacks) OVERRIDE;
73 virtual void remove(
74 const blink::WebURL& path,
75 blink::WebFileSystemCallbacks) OVERRIDE;
76 virtual void removeRecursively(
77 const blink::WebURL& path,
78 blink::WebFileSystemCallbacks) OVERRIDE;
79 virtual void readMetadata(
80 const blink::WebURL& path,
81 blink::WebFileSystemCallbacks) OVERRIDE;
82 virtual void createFile(
83 const blink::WebURL& path,
84 bool exclusive,
85 blink::WebFileSystemCallbacks) OVERRIDE;
86 virtual void createDirectory(
87 const blink::WebURL& path,
88 bool exclusive,
89 blink::WebFileSystemCallbacks) OVERRIDE;
90 virtual void fileExists(
91 const blink::WebURL& path,
92 blink::WebFileSystemCallbacks) OVERRIDE;
93 virtual void directoryExists(
94 const blink::WebURL& path,
95 blink::WebFileSystemCallbacks) OVERRIDE;
96 virtual int readDirectory(
97 const blink::WebURL& path,
98 blink::WebFileSystemCallbacks) OVERRIDE;
99 virtual void createFileWriter(
100 const blink::WebURL& path,
101 blink::WebFileWriterClient*,
102 blink::WebFileSystemCallbacks) OVERRIDE;
103 virtual void createSnapshotFileAndReadMetadata(
104 const blink::WebURL& path,
105 blink::WebFileSystemCallbacks);
106 virtual bool waitForAdditionalResult(int callbacksId);
108 int RegisterCallbacks(const blink::WebFileSystemCallbacks& callbacks);
109 blink::WebFileSystemCallbacks GetCallbacks(int callbacks_id);
110 void UnregisterCallbacks(int callbacks_id);
112 private:
113 typedef std::map<int, blink::WebFileSystemCallbacks> CallbacksMap;
114 typedef std::map<int, scoped_refptr<WaitableCallbackResults> >
115 WaitableCallbackResultsMap;
117 WaitableCallbackResults* MaybeCreateWaitableResults(
118 const blink::WebFileSystemCallbacks& callbacks, int callbacks_id);
120 scoped_refptr<base::MessageLoopProxy> main_thread_loop_;
122 CallbacksMap callbacks_;
123 int next_callbacks_id_;
124 WaitableCallbackResultsMap waitable_results_;
126 DISALLOW_COPY_AND_ASSIGN(WebFileSystemImpl);
129 } // namespace content
131 #endif // CONTENT_CHILD_FILEAPI_WEBFILESYSTEM_IMPL_H_