cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / content / child / fileapi / webfilesystem_impl.h
blobe9d6cc87a556444f8f69030e4ffee871099e8015
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/public/child/worker_thread.h"
15 #include "third_party/WebKit/public/platform/WebFileSystem.h"
17 namespace base {
18 class WaitableEvent;
19 class SingleThreadTaskRunner;
22 namespace blink {
23 class WebURL;
24 class WebFileWriter;
25 class WebFileWriterClient;
28 namespace content {
30 class WebFileSystemImpl : public blink::WebFileSystem,
31 public WorkerThread::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 const scoped_refptr<base::SingleThreadTaskRunner>&
41 main_thread_task_runner);
43 // Deletes thread-specific instance (if exists). For workers it deletes
44 // itself in WillStopCurrentWorkerThread(), but for an instance created on the
45 // main thread this method must be called.
46 static void DeleteThreadSpecificInstance();
48 explicit WebFileSystemImpl(
49 const scoped_refptr<base::SingleThreadTaskRunner>&
50 main_thread_task_runner);
51 virtual ~WebFileSystemImpl();
53 // WorkerThread::Observer implementation.
54 void WillStopCurrentWorkerThread() override;
56 // WebFileSystem implementation.
57 virtual void openFileSystem(
58 const blink::WebURL& storage_partition,
59 const blink::WebFileSystemType type,
60 blink::WebFileSystemCallbacks);
61 virtual void resolveURL(
62 const blink::WebURL& filesystem_url,
63 blink::WebFileSystemCallbacks) override;
64 virtual void deleteFileSystem(
65 const blink::WebURL& storage_partition,
66 const blink::WebFileSystemType type,
67 blink::WebFileSystemCallbacks);
68 virtual void move(
69 const blink::WebURL& src_path,
70 const blink::WebURL& dest_path,
71 blink::WebFileSystemCallbacks) override;
72 virtual void copy(
73 const blink::WebURL& src_path,
74 const blink::WebURL& dest_path,
75 blink::WebFileSystemCallbacks) override;
76 virtual void remove(
77 const blink::WebURL& path,
78 blink::WebFileSystemCallbacks) override;
79 virtual void removeRecursively(
80 const blink::WebURL& path,
81 blink::WebFileSystemCallbacks) override;
82 virtual void readMetadata(
83 const blink::WebURL& path,
84 blink::WebFileSystemCallbacks) override;
85 virtual void createFile(
86 const blink::WebURL& path,
87 bool exclusive,
88 blink::WebFileSystemCallbacks) override;
89 virtual void createDirectory(
90 const blink::WebURL& path,
91 bool exclusive,
92 blink::WebFileSystemCallbacks) override;
93 virtual void fileExists(
94 const blink::WebURL& path,
95 blink::WebFileSystemCallbacks) override;
96 virtual void directoryExists(
97 const blink::WebURL& path,
98 blink::WebFileSystemCallbacks) override;
99 virtual int readDirectory(
100 const blink::WebURL& path,
101 blink::WebFileSystemCallbacks) override;
102 virtual void createFileWriter(
103 const blink::WebURL& path,
104 blink::WebFileWriterClient*,
105 blink::WebFileSystemCallbacks) override;
106 virtual void createSnapshotFileAndReadMetadata(
107 const blink::WebURL& path,
108 blink::WebFileSystemCallbacks);
109 virtual bool waitForAdditionalResult(int callbacksId);
111 int RegisterCallbacks(const blink::WebFileSystemCallbacks& callbacks);
112 blink::WebFileSystemCallbacks GetCallbacks(int callbacks_id);
113 void UnregisterCallbacks(int callbacks_id);
115 private:
116 typedef std::map<int, blink::WebFileSystemCallbacks> CallbacksMap;
117 typedef std::map<int, scoped_refptr<WaitableCallbackResults> >
118 WaitableCallbackResultsMap;
120 WaitableCallbackResults* MaybeCreateWaitableResults(
121 const blink::WebFileSystemCallbacks& callbacks, int callbacks_id);
123 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
125 CallbacksMap callbacks_;
126 int next_callbacks_id_;
127 WaitableCallbackResultsMap waitable_results_;
129 DISALLOW_COPY_AND_ASSIGN(WebFileSystemImpl);
132 } // namespace content
134 #endif // CONTENT_CHILD_FILEAPI_WEBFILESYSTEM_IMPL_H_