Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Side by Side Diff: content/child/fileapi/webfilesystem_impl.h

Issue 188533002: Handle has_more correctly in WebFileSystemImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix race Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/child/fileapi/webfilesystem_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/child/worker_task_runner.h" 14 #include "content/child/worker_task_runner.h"
15 #include "third_party/WebKit/public/platform/WebFileSystem.h" 15 #include "third_party/WebKit/public/platform/WebFileSystem.h"
16 16
17 // TODO(hashimoto): Remove this hack.
18 #if defined(READ_DIRECTORY_RETURNS_INT)
19 #define READ_DIRECTORY_RETURN_TYPE int
20 #else
21 #define READ_DIRECTORY_RETURN_TYPE void
22 #endif
23
17 namespace base { 24 namespace base {
18 class MessageLoopProxy; 25 class MessageLoopProxy;
26 class WaitableEvent;
19 } 27 }
20 28
21 namespace blink { 29 namespace blink {
22 class WebURL; 30 class WebURL;
23 class WebFileWriter; 31 class WebFileWriter;
24 class WebFileWriterClient; 32 class WebFileWriterClient;
25 } 33 }
26 34
27 namespace content { 35 namespace content {
28 36
29 class WebFileSystemImpl : public blink::WebFileSystem, 37 class WebFileSystemImpl : public blink::WebFileSystem,
30 public WorkerTaskRunner::Observer, 38 public WorkerTaskRunner::Observer,
31 public base::NonThreadSafe { 39 public base::NonThreadSafe {
32 public: 40 public:
41 class WaitableCallbackResults;
42
33 // Returns thread-specific instance. If non-null |main_thread_loop| 43 // Returns thread-specific instance. If non-null |main_thread_loop|
34 // is given and no thread-specific instance has been created it may 44 // is given and no thread-specific instance has been created it may
35 // create a new instance. 45 // create a new instance.
36 static WebFileSystemImpl* ThreadSpecificInstance( 46 static WebFileSystemImpl* ThreadSpecificInstance(
37 base::MessageLoopProxy* main_thread_loop); 47 base::MessageLoopProxy* main_thread_loop);
38 48
39 // Deletes thread-specific instance (if exists). For workers it deletes 49 // Deletes thread-specific instance (if exists). For workers it deletes
40 // itself in OnWorkerRunLoopStopped(), but for an instance created on the 50 // itself in OnWorkerRunLoopStopped(), but for an instance created on the
41 // main thread this method must be called. 51 // main thread this method must be called.
42 static void DeleteThreadSpecificInstance(); 52 static void DeleteThreadSpecificInstance();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 virtual void createDirectory( 93 virtual void createDirectory(
84 const blink::WebURL& path, 94 const blink::WebURL& path,
85 bool exclusive, 95 bool exclusive,
86 blink::WebFileSystemCallbacks) OVERRIDE; 96 blink::WebFileSystemCallbacks) OVERRIDE;
87 virtual void fileExists( 97 virtual void fileExists(
88 const blink::WebURL& path, 98 const blink::WebURL& path,
89 blink::WebFileSystemCallbacks) OVERRIDE; 99 blink::WebFileSystemCallbacks) OVERRIDE;
90 virtual void directoryExists( 100 virtual void directoryExists(
91 const blink::WebURL& path, 101 const blink::WebURL& path,
92 blink::WebFileSystemCallbacks) OVERRIDE; 102 blink::WebFileSystemCallbacks) OVERRIDE;
93 virtual void readDirectory( 103 virtual READ_DIRECTORY_RETURN_TYPE readDirectory(
94 const blink::WebURL& path, 104 const blink::WebURL& path,
95 blink::WebFileSystemCallbacks) OVERRIDE; 105 blink::WebFileSystemCallbacks) OVERRIDE;
96 virtual void createFileWriter( 106 virtual void createFileWriter(
97 const blink::WebURL& path, 107 const blink::WebURL& path,
98 blink::WebFileWriterClient*, 108 blink::WebFileWriterClient*,
99 blink::WebFileSystemCallbacks) OVERRIDE; 109 blink::WebFileSystemCallbacks) OVERRIDE;
100 virtual void createSnapshotFileAndReadMetadata( 110 virtual void createSnapshotFileAndReadMetadata(
101 const blink::WebURL& path, 111 const blink::WebURL& path,
102 blink::WebFileSystemCallbacks); 112 blink::WebFileSystemCallbacks);
113 virtual bool waitForAdditionalResult(int callbacksId);
103 114
104 int RegisterCallbacks(const blink::WebFileSystemCallbacks& callbacks); 115 int RegisterCallbacks(const blink::WebFileSystemCallbacks& callbacks);
105 blink::WebFileSystemCallbacks GetAndUnregisterCallbacks( 116 blink::WebFileSystemCallbacks GetCallbacks(int callbacks_id);
106 int callbacks_id); 117 void UnregisterCallbacks(int callbacks_id);
107 118
108 private: 119 private:
109 typedef std::map<int, blink::WebFileSystemCallbacks> CallbacksMap; 120 typedef std::map<int, blink::WebFileSystemCallbacks> CallbacksMap;
121 typedef std::map<int, scoped_refptr<WaitableCallbackResults> >
122 WaitableCallbackResultsMap;
123
124 WaitableCallbackResults* MaybeCreateWaitableResults(
125 const blink::WebFileSystemCallbacks& callbacks, int callbacks_id);
110 126
111 scoped_refptr<base::MessageLoopProxy> main_thread_loop_; 127 scoped_refptr<base::MessageLoopProxy> main_thread_loop_;
112 128
113 CallbacksMap callbacks_; 129 CallbacksMap callbacks_;
114 int next_callbacks_id_; 130 int next_callbacks_id_;
131 WaitableCallbackResultsMap waitable_results_;
115 132
116 DISALLOW_COPY_AND_ASSIGN(WebFileSystemImpl); 133 DISALLOW_COPY_AND_ASSIGN(WebFileSystemImpl);
117 }; 134 };
118 135
119 } // namespace content 136 } // namespace content
120 137
121 #endif // CONTENT_CHILD_FILEAPI_WEBFILESYSTEM_IMPL_H_ 138 #endif // CONTENT_CHILD_FILEAPI_WEBFILESYSTEM_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | content/child/fileapi/webfilesystem_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698