OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_CHILD_FILEAPI_WEBFILESYSTEM_IMPL_H_ | 5 #ifndef CONTENT_CHILD_FILEAPI_WEBFILESYSTEM_IMPL_H_ |
6 #define CONTENT_CHILD_FILEAPI_WEBFILESYSTEM_IMPL_H_ | 6 #define CONTENT_CHILD_FILEAPI_WEBFILESYSTEM_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
14 #include "third_party/WebKit/public/platform/WebFileSystem.h" | 14 #include "third_party/WebKit/public/platform/WebFileSystem.h" |
15 #include "webkit/child/worker_task_runner.h" | 15 #include "webkit/child/worker_task_runner.h" |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class MessageLoopProxy; | 18 class MessageLoopProxy; |
19 } | 19 } |
20 | 20 |
21 namespace WebKit { | 21 namespace blink { |
22 class WebURL; | 22 class WebURL; |
23 class WebFileWriter; | 23 class WebFileWriter; |
24 class WebFileWriterClient; | 24 class WebFileWriterClient; |
25 } | 25 } |
26 | 26 |
27 namespace content { | 27 namespace content { |
28 | 28 |
29 class WebFileSystemImpl | 29 class WebFileSystemImpl |
30 : public WebKit::WebFileSystem, | 30 : public blink::WebFileSystem, |
31 public webkit_glue::WorkerTaskRunner::Observer, | 31 public webkit_glue::WorkerTaskRunner::Observer, |
32 public base::NonThreadSafe { | 32 public base::NonThreadSafe { |
33 public: | 33 public: |
34 // Returns thread-specific instance. If non-null |main_thread_loop| | 34 // Returns thread-specific instance. If non-null |main_thread_loop| |
35 // is given and no thread-specific instance has been created it may | 35 // is given and no thread-specific instance has been created it may |
36 // create a new instance. | 36 // create a new instance. |
37 static WebFileSystemImpl* ThreadSpecificInstance( | 37 static WebFileSystemImpl* ThreadSpecificInstance( |
38 base::MessageLoopProxy* main_thread_loop); | 38 base::MessageLoopProxy* main_thread_loop); |
39 | 39 |
40 // Deletes thread-specific instance (if exists). For workers it deletes | 40 // Deletes thread-specific instance (if exists). For workers it deletes |
41 // itself in OnWorkerRunLoopStopped(), but for an instance created on the | 41 // itself in OnWorkerRunLoopStopped(), but for an instance created on the |
42 // main thread this method must be called. | 42 // main thread this method must be called. |
43 static void DeleteThreadSpecificInstance(); | 43 static void DeleteThreadSpecificInstance(); |
44 | 44 |
45 explicit WebFileSystemImpl(base::MessageLoopProxy* main_thread_loop); | 45 explicit WebFileSystemImpl(base::MessageLoopProxy* main_thread_loop); |
46 virtual ~WebFileSystemImpl(); | 46 virtual ~WebFileSystemImpl(); |
47 | 47 |
48 // webkit_glue::WorkerTaskRunner::Observer implementation. | 48 // webkit_glue::WorkerTaskRunner::Observer implementation. |
49 virtual void OnWorkerRunLoopStopped() OVERRIDE; | 49 virtual void OnWorkerRunLoopStopped() OVERRIDE; |
50 | 50 |
51 // WebFileSystem implementation. | 51 // WebFileSystem implementation. |
52 virtual void openFileSystem( | 52 virtual void openFileSystem( |
53 const WebKit::WebURL& storage_partition, | 53 const blink::WebURL& storage_partition, |
54 const WebKit::WebFileSystemType type, | 54 const blink::WebFileSystemType type, |
55 WebKit::WebFileSystemCallbacks); | 55 blink::WebFileSystemCallbacks); |
56 virtual void resolveURL( | 56 virtual void resolveURL( |
57 const WebKit::WebURL& filesystem_url, | 57 const blink::WebURL& filesystem_url, |
58 WebKit::WebFileSystemCallbacks) OVERRIDE; | 58 blink::WebFileSystemCallbacks) OVERRIDE; |
59 virtual void deleteFileSystem( | 59 virtual void deleteFileSystem( |
60 const WebKit::WebURL& storage_partition, | 60 const blink::WebURL& storage_partition, |
61 const WebKit::WebFileSystemType type, | 61 const blink::WebFileSystemType type, |
62 WebKit::WebFileSystemCallbacks); | 62 blink::WebFileSystemCallbacks); |
63 virtual void move( | 63 virtual void move( |
64 const WebKit::WebURL& src_path, | 64 const blink::WebURL& src_path, |
65 const WebKit::WebURL& dest_path, | 65 const blink::WebURL& dest_path, |
66 WebKit::WebFileSystemCallbacks) OVERRIDE; | 66 blink::WebFileSystemCallbacks) OVERRIDE; |
67 virtual void copy( | 67 virtual void copy( |
68 const WebKit::WebURL& src_path, | 68 const blink::WebURL& src_path, |
69 const WebKit::WebURL& dest_path, | 69 const blink::WebURL& dest_path, |
70 WebKit::WebFileSystemCallbacks) OVERRIDE; | 70 blink::WebFileSystemCallbacks) OVERRIDE; |
71 virtual void remove( | 71 virtual void remove( |
72 const WebKit::WebURL& path, | 72 const blink::WebURL& path, |
73 WebKit::WebFileSystemCallbacks) OVERRIDE; | 73 blink::WebFileSystemCallbacks) OVERRIDE; |
74 virtual void removeRecursively( | 74 virtual void removeRecursively( |
75 const WebKit::WebURL& path, | 75 const blink::WebURL& path, |
76 WebKit::WebFileSystemCallbacks) OVERRIDE; | 76 blink::WebFileSystemCallbacks) OVERRIDE; |
77 virtual void readMetadata( | 77 virtual void readMetadata( |
78 const WebKit::WebURL& path, | 78 const blink::WebURL& path, |
79 WebKit::WebFileSystemCallbacks) OVERRIDE; | 79 blink::WebFileSystemCallbacks) OVERRIDE; |
80 virtual void createFile( | 80 virtual void createFile( |
81 const WebKit::WebURL& path, | 81 const blink::WebURL& path, |
82 bool exclusive, | 82 bool exclusive, |
83 WebKit::WebFileSystemCallbacks) OVERRIDE; | 83 blink::WebFileSystemCallbacks) OVERRIDE; |
84 virtual void createDirectory( | 84 virtual void createDirectory( |
85 const WebKit::WebURL& path, | 85 const blink::WebURL& path, |
86 bool exclusive, | 86 bool exclusive, |
87 WebKit::WebFileSystemCallbacks) OVERRIDE; | 87 blink::WebFileSystemCallbacks) OVERRIDE; |
88 virtual void fileExists( | 88 virtual void fileExists( |
89 const WebKit::WebURL& path, | 89 const blink::WebURL& path, |
90 WebKit::WebFileSystemCallbacks) OVERRIDE; | 90 blink::WebFileSystemCallbacks) OVERRIDE; |
91 virtual void directoryExists( | 91 virtual void directoryExists( |
92 const WebKit::WebURL& path, | 92 const blink::WebURL& path, |
93 WebKit::WebFileSystemCallbacks) OVERRIDE; | 93 blink::WebFileSystemCallbacks) OVERRIDE; |
94 virtual void readDirectory( | 94 virtual void readDirectory( |
95 const WebKit::WebURL& path, | 95 const blink::WebURL& path, |
96 WebKit::WebFileSystemCallbacks) OVERRIDE; | 96 blink::WebFileSystemCallbacks) OVERRIDE; |
97 virtual void createFileWriter( | 97 virtual void createFileWriter( |
98 const WebKit::WebURL& path, | 98 const blink::WebURL& path, |
99 WebKit::WebFileWriterClient*, | 99 blink::WebFileWriterClient*, |
100 WebKit::WebFileSystemCallbacks) OVERRIDE; | 100 blink::WebFileSystemCallbacks) OVERRIDE; |
101 virtual void createSnapshotFileAndReadMetadata( | 101 virtual void createSnapshotFileAndReadMetadata( |
102 const WebKit::WebURL& path, | 102 const blink::WebURL& path, |
103 WebKit::WebFileSystemCallbacks); | 103 blink::WebFileSystemCallbacks); |
104 | 104 |
105 int RegisterCallbacks(const WebKit::WebFileSystemCallbacks& callbacks); | 105 int RegisterCallbacks(const blink::WebFileSystemCallbacks& callbacks); |
106 WebKit::WebFileSystemCallbacks GetAndUnregisterCallbacks( | 106 blink::WebFileSystemCallbacks GetAndUnregisterCallbacks( |
107 int callbacks_id); | 107 int callbacks_id); |
108 | 108 |
109 private: | 109 private: |
110 typedef std::map<int, WebKit::WebFileSystemCallbacks> CallbacksMap; | 110 typedef std::map<int, blink::WebFileSystemCallbacks> CallbacksMap; |
111 | 111 |
112 scoped_refptr<base::MessageLoopProxy> main_thread_loop_; | 112 scoped_refptr<base::MessageLoopProxy> main_thread_loop_; |
113 | 113 |
114 CallbacksMap callbacks_; | 114 CallbacksMap callbacks_; |
115 int next_callbacks_id_; | 115 int next_callbacks_id_; |
116 | 116 |
117 DISALLOW_COPY_AND_ASSIGN(WebFileSystemImpl); | 117 DISALLOW_COPY_AND_ASSIGN(WebFileSystemImpl); |
118 }; | 118 }; |
119 | 119 |
120 } // namespace content | 120 } // namespace content |
121 | 121 |
122 #endif // CONTENT_CHILD_FILEAPI_WEBFILESYSTEM_IMPL_H_ | 122 #endif // CONTENT_CHILD_FILEAPI_WEBFILESYSTEM_IMPL_H_ |
OLD | NEW |