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

Side by Side Diff: content/common/file_system/file_system_dispatcher.cc

Issue 6767010: More filesystem cleanup: convert URL-encoded-as-FilePath to actual URL, where (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "content/common/file_system/file_system_dispatcher.h" 5 #include "content/common/file_system/file_system_dispatcher.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "content/common/child_thread.h" 8 #include "content/common/child_thread.h"
9 #include "content/common/file_system_messages.h" 9 #include "content/common/file_system_messages.h"
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 if (!ChildThread::current()->Send(new FileSystemHostMsg_Open( 45 if (!ChildThread::current()->Send(new FileSystemHostMsg_Open(
46 request_id, origin_url, type, size, create))) { 46 request_id, origin_url, type, size, create))) {
47 dispatchers_.Remove(request_id); // destroys |dispatcher| 47 dispatchers_.Remove(request_id); // destroys |dispatcher|
48 return false; 48 return false;
49 } 49 }
50 50
51 return true; 51 return true;
52 } 52 }
53 53
54 bool FileSystemDispatcher::Move( 54 bool FileSystemDispatcher::Move(
55 const FilePath& src_path, 55 const GURL& src_path,
56 const FilePath& dest_path, 56 const GURL& dest_path,
57 fileapi::FileSystemCallbackDispatcher* dispatcher) { 57 fileapi::FileSystemCallbackDispatcher* dispatcher) {
58 int request_id = dispatchers_.Add(dispatcher); 58 int request_id = dispatchers_.Add(dispatcher);
59 if (!ChildThread::current()->Send(new FileSystemHostMsg_Move( 59 if (!ChildThread::current()->Send(new FileSystemHostMsg_Move(
60 request_id, src_path, dest_path))) { 60 request_id, src_path, dest_path))) {
61 dispatchers_.Remove(request_id); // destroys |dispatcher| 61 dispatchers_.Remove(request_id); // destroys |dispatcher|
62 return false; 62 return false;
63 } 63 }
64 64
65 return true; 65 return true;
66 } 66 }
67 67
68 bool FileSystemDispatcher::Copy( 68 bool FileSystemDispatcher::Copy(
69 const FilePath& src_path, 69 const GURL& src_path,
70 const FilePath& dest_path, 70 const GURL& dest_path,
71 fileapi::FileSystemCallbackDispatcher* dispatcher) { 71 fileapi::FileSystemCallbackDispatcher* dispatcher) {
72 int request_id = dispatchers_.Add(dispatcher); 72 int request_id = dispatchers_.Add(dispatcher);
73 if (!ChildThread::current()->Send(new FileSystemHostMsg_Copy( 73 if (!ChildThread::current()->Send(new FileSystemHostMsg_Copy(
74 request_id, src_path, dest_path))) { 74 request_id, src_path, dest_path))) {
75 dispatchers_.Remove(request_id); // destroys |dispatcher| 75 dispatchers_.Remove(request_id); // destroys |dispatcher|
76 return false; 76 return false;
77 } 77 }
78 78
79 return true; 79 return true;
80 } 80 }
81 81
82 bool FileSystemDispatcher::Remove( 82 bool FileSystemDispatcher::Remove(
83 const FilePath& path, 83 const GURL& path,
84 bool recursive, 84 bool recursive,
85 fileapi::FileSystemCallbackDispatcher* dispatcher) { 85 fileapi::FileSystemCallbackDispatcher* dispatcher) {
86 int request_id = dispatchers_.Add(dispatcher); 86 int request_id = dispatchers_.Add(dispatcher);
87 if (!ChildThread::current()->Send( 87 if (!ChildThread::current()->Send(
88 new FileSystemMsg_Remove(request_id, path, recursive))) { 88 new FileSystemMsg_Remove(request_id, path, recursive))) {
89 dispatchers_.Remove(request_id); // destroys |dispatcher| 89 dispatchers_.Remove(request_id); // destroys |dispatcher|
90 return false; 90 return false;
91 } 91 }
92 92
93 return true; 93 return true;
94 } 94 }
95 95
96 bool FileSystemDispatcher::ReadMetadata( 96 bool FileSystemDispatcher::ReadMetadata(
97 const FilePath& path, 97 const GURL& path,
98 fileapi::FileSystemCallbackDispatcher* dispatcher) { 98 fileapi::FileSystemCallbackDispatcher* dispatcher) {
99 int request_id = dispatchers_.Add(dispatcher); 99 int request_id = dispatchers_.Add(dispatcher);
100 if (!ChildThread::current()->Send( 100 if (!ChildThread::current()->Send(
101 new FileSystemHostMsg_ReadMetadata(request_id, path))) { 101 new FileSystemHostMsg_ReadMetadata(request_id, path))) {
102 dispatchers_.Remove(request_id); // destroys |dispatcher| 102 dispatchers_.Remove(request_id); // destroys |dispatcher|
103 return false; 103 return false;
104 } 104 }
105 105
106 return true; 106 return true;
107 } 107 }
108 108
109 bool FileSystemDispatcher::Create( 109 bool FileSystemDispatcher::Create(
110 const FilePath& path, 110 const GURL& path,
111 bool exclusive, 111 bool exclusive,
112 bool is_directory, 112 bool is_directory,
113 bool recursive, 113 bool recursive,
114 fileapi::FileSystemCallbackDispatcher* dispatcher) { 114 fileapi::FileSystemCallbackDispatcher* dispatcher) {
115 int request_id = dispatchers_.Add(dispatcher); 115 int request_id = dispatchers_.Add(dispatcher);
116 if (!ChildThread::current()->Send(new FileSystemHostMsg_Create( 116 if (!ChildThread::current()->Send(new FileSystemHostMsg_Create(
117 request_id, path, exclusive, is_directory, recursive))) { 117 request_id, path, exclusive, is_directory, recursive))) {
118 dispatchers_.Remove(request_id); // destroys |dispatcher| 118 dispatchers_.Remove(request_id); // destroys |dispatcher|
119 return false; 119 return false;
120 } 120 }
121 121
122 return true; 122 return true;
123 } 123 }
124 124
125 bool FileSystemDispatcher::Exists( 125 bool FileSystemDispatcher::Exists(
126 const FilePath& path, 126 const GURL& path,
127 bool is_directory, 127 bool is_directory,
128 fileapi::FileSystemCallbackDispatcher* dispatcher) { 128 fileapi::FileSystemCallbackDispatcher* dispatcher) {
129 int request_id = dispatchers_.Add(dispatcher); 129 int request_id = dispatchers_.Add(dispatcher);
130 if (!ChildThread::current()->Send( 130 if (!ChildThread::current()->Send(
131 new FileSystemHostMsg_Exists(request_id, path, is_directory))) { 131 new FileSystemHostMsg_Exists(request_id, path, is_directory))) {
132 dispatchers_.Remove(request_id); // destroys |dispatcher| 132 dispatchers_.Remove(request_id); // destroys |dispatcher|
133 return false; 133 return false;
134 } 134 }
135 135
136 return true; 136 return true;
137 } 137 }
138 138
139 bool FileSystemDispatcher::ReadDirectory( 139 bool FileSystemDispatcher::ReadDirectory(
140 const FilePath& path, 140 const GURL& path,
141 fileapi::FileSystemCallbackDispatcher* dispatcher) { 141 fileapi::FileSystemCallbackDispatcher* dispatcher) {
142 int request_id = dispatchers_.Add(dispatcher); 142 int request_id = dispatchers_.Add(dispatcher);
143 if (!ChildThread::current()->Send( 143 if (!ChildThread::current()->Send(
144 new FileSystemHostMsg_ReadDirectory(request_id, path))) { 144 new FileSystemHostMsg_ReadDirectory(request_id, path))) {
145 dispatchers_.Remove(request_id); // destroys |dispatcher| 145 dispatchers_.Remove(request_id); // destroys |dispatcher|
146 return false; 146 return false;
147 } 147 }
148 148
149 return true; 149 return true;
150 } 150 }
151 151
152 bool FileSystemDispatcher::Truncate( 152 bool FileSystemDispatcher::Truncate(
153 const FilePath& path, 153 const GURL& path,
154 int64 offset, 154 int64 offset,
155 int* request_id_out, 155 int* request_id_out,
156 fileapi::FileSystemCallbackDispatcher* dispatcher) { 156 fileapi::FileSystemCallbackDispatcher* dispatcher) {
157 int request_id = dispatchers_.Add(dispatcher); 157 int request_id = dispatchers_.Add(dispatcher);
158 if (!ChildThread::current()->Send( 158 if (!ChildThread::current()->Send(
159 new FileSystemHostMsg_Truncate(request_id, path, offset))) { 159 new FileSystemHostMsg_Truncate(request_id, path, offset))) {
160 dispatchers_.Remove(request_id); // destroys |dispatcher| 160 dispatchers_.Remove(request_id); // destroys |dispatcher|
161 return false; 161 return false;
162 } 162 }
163 163
164 if (request_id_out) 164 if (request_id_out)
165 *request_id_out = request_id; 165 *request_id_out = request_id;
166 return true; 166 return true;
167 } 167 }
168 168
169 bool FileSystemDispatcher::Write( 169 bool FileSystemDispatcher::Write(
170 const FilePath& path, 170 const GURL& path,
171 const GURL& blob_url, 171 const GURL& blob_url,
172 int64 offset, 172 int64 offset,
173 int* request_id_out, 173 int* request_id_out,
174 fileapi::FileSystemCallbackDispatcher* dispatcher) { 174 fileapi::FileSystemCallbackDispatcher* dispatcher) {
175 int request_id = dispatchers_.Add(dispatcher); 175 int request_id = dispatchers_.Add(dispatcher);
176 if (!ChildThread::current()->Send( 176 if (!ChildThread::current()->Send(
177 new FileSystemHostMsg_Write(request_id, path, blob_url, offset))) { 177 new FileSystemHostMsg_Write(request_id, path, blob_url, offset))) {
178 dispatchers_.Remove(request_id); // destroys |dispatcher| 178 dispatchers_.Remove(request_id); // destroys |dispatcher|
179 return false; 179 return false;
180 } 180 }
(...skipping 10 matching lines...) Expand all
191 if (!ChildThread::current()->Send(new FileSystemHostMsg_CancelWrite( 191 if (!ChildThread::current()->Send(new FileSystemHostMsg_CancelWrite(
192 request_id, request_id_to_cancel))) { 192 request_id, request_id_to_cancel))) {
193 dispatchers_.Remove(request_id); // destroys |dispatcher| 193 dispatchers_.Remove(request_id); // destroys |dispatcher|
194 return false; 194 return false;
195 } 195 }
196 196
197 return true; 197 return true;
198 } 198 }
199 199
200 bool FileSystemDispatcher::TouchFile( 200 bool FileSystemDispatcher::TouchFile(
201 const FilePath& path, 201 const GURL& path,
202 const base::Time& last_access_time, 202 const base::Time& last_access_time,
203 const base::Time& last_modified_time, 203 const base::Time& last_modified_time,
204 fileapi::FileSystemCallbackDispatcher* dispatcher) { 204 fileapi::FileSystemCallbackDispatcher* dispatcher) {
205 int request_id = dispatchers_.Add(dispatcher); 205 int request_id = dispatchers_.Add(dispatcher);
206 if (!ChildThread::current()->Send( 206 if (!ChildThread::current()->Send(
207 new FileSystemHostMsg_TouchFile( 207 new FileSystemHostMsg_TouchFile(
208 request_id, path, last_access_time, last_modified_time))) { 208 request_id, path, last_access_time, last_modified_time))) {
209 dispatchers_.Remove(request_id); // destroys |dispatcher| 209 dispatchers_.Remove(request_id); // destroys |dispatcher|
210 return false; 210 return false;
211 } 211 }
212 212
213 return true; 213 return true;
214 } 214 }
215 215
216 void FileSystemDispatcher::OnOpenComplete( 216 void FileSystemDispatcher::OnOpenComplete(
217 int request_id, bool accepted, const std::string& name, 217 int request_id, bool accepted, const std::string& name,
218 const FilePath& root_path) { 218 const GURL& root) {
219 fileapi::FileSystemCallbackDispatcher* dispatcher = 219 fileapi::FileSystemCallbackDispatcher* dispatcher =
220 dispatchers_.Lookup(request_id); 220 dispatchers_.Lookup(request_id);
221 DCHECK(dispatcher); 221 DCHECK(dispatcher);
222 if (accepted) 222 if (accepted)
223 dispatcher->DidOpenFileSystem(name, root_path); 223 dispatcher->DidOpenFileSystem(name, root);
224 else 224 else
225 dispatcher->DidFail(base::PLATFORM_FILE_ERROR_SECURITY); 225 dispatcher->DidFail(base::PLATFORM_FILE_ERROR_SECURITY);
226 dispatchers_.Remove(request_id); 226 dispatchers_.Remove(request_id);
227 } 227 }
228 228
229 void FileSystemDispatcher::OnDidSucceed(int request_id) { 229 void FileSystemDispatcher::OnDidSucceed(int request_id) {
230 fileapi::FileSystemCallbackDispatcher* dispatcher = 230 fileapi::FileSystemCallbackDispatcher* dispatcher =
231 dispatchers_.Lookup(request_id); 231 dispatchers_.Lookup(request_id);
232 DCHECK(dispatcher); 232 DCHECK(dispatcher);
233 dispatcher->DidSucceed(); 233 dispatcher->DidSucceed();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 266
267 void FileSystemDispatcher::OnDidWrite( 267 void FileSystemDispatcher::OnDidWrite(
268 int request_id, int64 bytes, bool complete) { 268 int request_id, int64 bytes, bool complete) {
269 fileapi::FileSystemCallbackDispatcher* dispatcher = 269 fileapi::FileSystemCallbackDispatcher* dispatcher =
270 dispatchers_.Lookup(request_id); 270 dispatchers_.Lookup(request_id);
271 DCHECK(dispatcher); 271 DCHECK(dispatcher);
272 dispatcher->DidWrite(bytes, complete); 272 dispatcher->DidWrite(bytes, complete);
273 if (complete) 273 if (complete)
274 dispatchers_.Remove(request_id); 274 dispatchers_.Remove(request_id);
275 } 275 }
OLDNEW
« no previous file with comments | « content/common/file_system/file_system_dispatcher.h ('k') | content/common/file_system/webfilesystem_callback_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698