| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/file_system/file_system_dispatcher_host.h" | 5 #include "content/browser/file_system/file_system_dispatcher_host.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | |
| 11 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 12 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/platform_file.h" | 12 #include "base/platform_file.h" |
| 14 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
| 15 #include "base/time.h" | 14 #include "base/time.h" |
| 16 #include "content/common/file_system_messages.h" | 15 #include "content/common/file_system_messages.h" |
| 17 #include "content/public/browser/user_metrics.h" | 16 #include "content/public/browser/user_metrics.h" |
| 18 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
| 19 #include "ipc/ipc_platform_file.h" | 18 #include "ipc/ipc_platform_file.h" |
| 20 #include "net/url_request/url_request_context.h" | 19 #include "net/url_request/url_request_context.h" |
| 21 #include "net/url_request/url_request_context_getter.h" | 20 #include "net/url_request/url_request_context_getter.h" |
| 21 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
| 22 #include "webkit/fileapi/file_system_context.h" | 22 #include "webkit/fileapi/file_system_context.h" |
| 23 #include "webkit/fileapi/file_system_operation.h" | 23 #include "webkit/fileapi/file_system_operation.h" |
| 24 #include "webkit/fileapi/file_system_quota_util.h" | 24 #include "webkit/fileapi/file_system_quota_util.h" |
| 25 #include "webkit/fileapi/file_system_util.h" | 25 #include "webkit/fileapi/file_system_util.h" |
| 26 #include "webkit/fileapi/sandbox_mount_point_provider.h" | 26 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
| 27 | 27 |
| 28 using content::BrowserMessageFilter; | 28 using content::BrowserMessageFilter; |
| 29 using content::BrowserThread; | 29 using content::BrowserThread; |
| 30 using content::UserMetricsAction; | 30 using content::UserMetricsAction; |
| 31 using fileapi::FileSystemCallbackDispatcher; |
| 31 using fileapi::FileSystemFileUtil; | 32 using fileapi::FileSystemFileUtil; |
| 32 using fileapi::FileSystemOperation; | 33 using fileapi::FileSystemOperation; |
| 33 using fileapi::FileSystemOperationInterface; | 34 using fileapi::FileSystemOperationInterface; |
| 34 | 35 |
| 36 class BrowserFileSystemCallbackDispatcher |
| 37 : public FileSystemCallbackDispatcher { |
| 38 public: |
| 39 // An instance of this class must be created by Create() |
| 40 // (so that we do not leak ownerships). |
| 41 static scoped_ptr<FileSystemCallbackDispatcher> Create( |
| 42 FileSystemDispatcherHost* dispatcher_host, int request_id) { |
| 43 return scoped_ptr<FileSystemCallbackDispatcher>( |
| 44 new BrowserFileSystemCallbackDispatcher(dispatcher_host, request_id)); |
| 45 } |
| 46 |
| 47 virtual ~BrowserFileSystemCallbackDispatcher() { |
| 48 dispatcher_host_->UnregisterOperation(request_id_); |
| 49 } |
| 50 |
| 51 virtual void DidSucceed() { |
| 52 dispatcher_host_->Send(new FileSystemMsg_DidSucceed(request_id_)); |
| 53 } |
| 54 |
| 55 virtual void DidReadMetadata( |
| 56 const base::PlatformFileInfo& info, |
| 57 const FilePath& platform_path) { |
| 58 dispatcher_host_->Send(new FileSystemMsg_DidReadMetadata( |
| 59 request_id_, info, platform_path)); |
| 60 } |
| 61 |
| 62 virtual void DidReadDirectory( |
| 63 const std::vector<base::FileUtilProxy::Entry>& entries, bool has_more) { |
| 64 dispatcher_host_->Send(new FileSystemMsg_DidReadDirectory( |
| 65 request_id_, entries, has_more)); |
| 66 } |
| 67 |
| 68 virtual void DidOpenFileSystem(const std::string& name, |
| 69 const GURL& root) { |
| 70 DCHECK(root.is_valid()); |
| 71 dispatcher_host_->Send( |
| 72 new FileSystemMsg_DidOpenFileSystem(request_id_, name, root)); |
| 73 } |
| 74 |
| 75 virtual void DidFail(base::PlatformFileError error_code) { |
| 76 dispatcher_host_->Send(new FileSystemMsg_DidFail(request_id_, error_code)); |
| 77 } |
| 78 |
| 79 virtual void DidWrite(int64 bytes, bool complete) { |
| 80 dispatcher_host_->Send(new FileSystemMsg_DidWrite( |
| 81 request_id_, bytes, complete)); |
| 82 } |
| 83 |
| 84 virtual void DidOpenFile( |
| 85 base::PlatformFile file, |
| 86 base::ProcessHandle peer_handle) { |
| 87 IPC::PlatformFileForTransit file_for_transit = |
| 88 file != base::kInvalidPlatformFileValue ? |
| 89 IPC::GetFileHandleForProcess(file, peer_handle, true) : |
| 90 IPC::InvalidPlatformFileForTransit(); |
| 91 |
| 92 dispatcher_host_->Send(new FileSystemMsg_DidOpenFile( |
| 93 request_id_, file_for_transit)); |
| 94 } |
| 95 |
| 96 private: |
| 97 BrowserFileSystemCallbackDispatcher( |
| 98 FileSystemDispatcherHost* dispatcher_host, int request_id) |
| 99 : dispatcher_host_(dispatcher_host), |
| 100 request_id_(request_id) { |
| 101 DCHECK(dispatcher_host_); |
| 102 } |
| 103 |
| 104 scoped_refptr<FileSystemDispatcherHost> dispatcher_host_; |
| 105 int request_id_; |
| 106 }; |
| 107 |
| 35 FileSystemDispatcherHost::FileSystemDispatcherHost( | 108 FileSystemDispatcherHost::FileSystemDispatcherHost( |
| 36 net::URLRequestContextGetter* request_context_getter, | 109 net::URLRequestContextGetter* request_context_getter, |
| 37 fileapi::FileSystemContext* file_system_context) | 110 fileapi::FileSystemContext* file_system_context) |
| 38 : context_(file_system_context), | 111 : context_(file_system_context), |
| 39 request_context_getter_(request_context_getter), | 112 request_context_getter_(request_context_getter), |
| 40 request_context_(NULL) { | 113 request_context_(NULL) { |
| 41 DCHECK(context_); | 114 DCHECK(context_); |
| 42 DCHECK(request_context_getter_); | 115 DCHECK(request_context_getter_); |
| 43 } | 116 } |
| 44 | 117 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } | 173 } |
| 101 | 174 |
| 102 void FileSystemDispatcherHost::OnOpen( | 175 void FileSystemDispatcherHost::OnOpen( |
| 103 int request_id, const GURL& origin_url, fileapi::FileSystemType type, | 176 int request_id, const GURL& origin_url, fileapi::FileSystemType type, |
| 104 int64 requested_size, bool create) { | 177 int64 requested_size, bool create) { |
| 105 if (type == fileapi::kFileSystemTypeTemporary) { | 178 if (type == fileapi::kFileSystemTypeTemporary) { |
| 106 content::RecordAction(UserMetricsAction("OpenFileSystemTemporary")); | 179 content::RecordAction(UserMetricsAction("OpenFileSystemTemporary")); |
| 107 } else if (type == fileapi::kFileSystemTypePersistent) { | 180 } else if (type == fileapi::kFileSystemTypePersistent) { |
| 108 content::RecordAction(UserMetricsAction("OpenFileSystemPersistent")); | 181 content::RecordAction(UserMetricsAction("OpenFileSystemPersistent")); |
| 109 } | 182 } |
| 110 context_->OpenFileSystem(origin_url, type, create, base::Bind( | 183 context_->OpenFileSystem(origin_url, type, create, |
| 111 &FileSystemDispatcherHost::DidOpenFileSystem, this, request_id)); | 184 BrowserFileSystemCallbackDispatcher::Create( |
| 185 this, request_id)); |
| 112 } | 186 } |
| 113 | 187 |
| 114 void FileSystemDispatcherHost::OnMove( | 188 void FileSystemDispatcherHost::OnMove( |
| 115 int request_id, const GURL& src_path, const GURL& dest_path) { | 189 int request_id, const GURL& src_path, const GURL& dest_path) { |
| 116 GetNewOperation(src_path, request_id)->Move( | 190 GetNewOperation(src_path, request_id)->Move(src_path, dest_path); |
| 117 src_path, dest_path, | |
| 118 base::Bind(&FileSystemDispatcherHost::DidFinish, this, request_id)); | |
| 119 } | 191 } |
| 120 | 192 |
| 121 void FileSystemDispatcherHost::OnCopy( | 193 void FileSystemDispatcherHost::OnCopy( |
| 122 int request_id, const GURL& src_path, const GURL& dest_path) { | 194 int request_id, const GURL& src_path, const GURL& dest_path) { |
| 123 GetNewOperation(src_path, request_id)->Copy( | 195 GetNewOperation(src_path, request_id)->Copy(src_path, dest_path); |
| 124 src_path, dest_path, | |
| 125 base::Bind(&FileSystemDispatcherHost::DidFinish, this, request_id)); | |
| 126 } | 196 } |
| 127 | 197 |
| 128 void FileSystemDispatcherHost::OnRemove( | 198 void FileSystemDispatcherHost::OnRemove( |
| 129 int request_id, const GURL& path, bool recursive) { | 199 int request_id, const GURL& path, bool recursive) { |
| 130 GetNewOperation(path, request_id)->Remove( | 200 GetNewOperation(path, request_id)->Remove(path, recursive); |
| 131 path, recursive, | |
| 132 base::Bind(&FileSystemDispatcherHost::DidFinish, this, request_id)); | |
| 133 } | 201 } |
| 134 | 202 |
| 135 void FileSystemDispatcherHost::OnReadMetadata( | 203 void FileSystemDispatcherHost::OnReadMetadata( |
| 136 int request_id, const GURL& path) { | 204 int request_id, const GURL& path) { |
| 137 GetNewOperation(path, request_id)->GetMetadata( | 205 GetNewOperation(path, request_id)->GetMetadata(path); |
| 138 path, | |
| 139 base::Bind(&FileSystemDispatcherHost::DidGetMetadata, this, request_id)); | |
| 140 } | 206 } |
| 141 | 207 |
| 142 void FileSystemDispatcherHost::OnCreate( | 208 void FileSystemDispatcherHost::OnCreate( |
| 143 int request_id, const GURL& path, bool exclusive, | 209 int request_id, const GURL& path, bool exclusive, |
| 144 bool is_directory, bool recursive) { | 210 bool is_directory, bool recursive) { |
| 145 if (is_directory) { | 211 if (is_directory) |
| 146 GetNewOperation(path, request_id)->CreateDirectory( | 212 GetNewOperation(path, request_id)->CreateDirectory( |
| 147 path, exclusive, recursive, | 213 path, exclusive, recursive); |
| 148 base::Bind(&FileSystemDispatcherHost::DidFinish, this, request_id)); | 214 else |
| 149 } else { | 215 GetNewOperation(path, request_id)->CreateFile(path, exclusive); |
| 150 GetNewOperation(path, request_id)->CreateFile( | |
| 151 path, exclusive, | |
| 152 base::Bind(&FileSystemDispatcherHost::DidFinish, this, request_id)); | |
| 153 } | |
| 154 } | 216 } |
| 155 | 217 |
| 156 void FileSystemDispatcherHost::OnExists( | 218 void FileSystemDispatcherHost::OnExists( |
| 157 int request_id, const GURL& path, bool is_directory) { | 219 int request_id, const GURL& path, bool is_directory) { |
| 158 if (is_directory) { | 220 if (is_directory) |
| 159 GetNewOperation(path, request_id)->DirectoryExists( | 221 GetNewOperation(path, request_id)->DirectoryExists(path); |
| 160 path, | 222 else |
| 161 base::Bind(&FileSystemDispatcherHost::DidFinish, this, request_id)); | 223 GetNewOperation(path, request_id)->FileExists(path); |
| 162 } else { | |
| 163 GetNewOperation(path, request_id)->FileExists( | |
| 164 path, | |
| 165 base::Bind(&FileSystemDispatcherHost::DidFinish, this, request_id)); | |
| 166 } | |
| 167 } | 224 } |
| 168 | 225 |
| 169 void FileSystemDispatcherHost::OnReadDirectory( | 226 void FileSystemDispatcherHost::OnReadDirectory( |
| 170 int request_id, const GURL& path) { | 227 int request_id, const GURL& path) { |
| 171 GetNewOperation(path, request_id)->ReadDirectory( | 228 GetNewOperation(path, request_id)->ReadDirectory(path); |
| 172 path, base::Bind(&FileSystemDispatcherHost::DidReadDirectory, | |
| 173 this, request_id)); | |
| 174 } | 229 } |
| 175 | 230 |
| 176 void FileSystemDispatcherHost::OnWrite( | 231 void FileSystemDispatcherHost::OnWrite( |
| 177 int request_id, | 232 int request_id, |
| 178 const GURL& path, | 233 const GURL& path, |
| 179 const GURL& blob_url, | 234 const GURL& blob_url, |
| 180 int64 offset) { | 235 int64 offset) { |
| 181 if (!request_context_) { | 236 if (!request_context_) { |
| 182 // We can't write w/o a request context, trying to do so will crash. | 237 // We can't write w/o a request context, trying to do so will crash. |
| 183 NOTREACHED(); | 238 NOTREACHED(); |
| 184 return; | 239 return; |
| 185 } | 240 } |
| 186 GetNewOperation(path, request_id)->Write( | 241 GetNewOperation(path, request_id)->Write( |
| 187 request_context_, path, blob_url, offset, | 242 request_context_, path, blob_url, offset); |
| 188 base::Bind(&FileSystemDispatcherHost::DidWrite, this, request_id)); | |
| 189 } | 243 } |
| 190 | 244 |
| 191 void FileSystemDispatcherHost::OnTruncate( | 245 void FileSystemDispatcherHost::OnTruncate( |
| 192 int request_id, | 246 int request_id, |
| 193 const GURL& path, | 247 const GURL& path, |
| 194 int64 length) { | 248 int64 length) { |
| 195 GetNewOperation(path, request_id)->Truncate( | 249 GetNewOperation(path, request_id)->Truncate(path, length); |
| 196 path, length, | |
| 197 base::Bind(&FileSystemDispatcherHost::DidFinish, this, request_id)); | |
| 198 } | 250 } |
| 199 | 251 |
| 200 void FileSystemDispatcherHost::OnTouchFile( | 252 void FileSystemDispatcherHost::OnTouchFile( |
| 201 int request_id, | 253 int request_id, |
| 202 const GURL& path, | 254 const GURL& path, |
| 203 const base::Time& last_access_time, | 255 const base::Time& last_access_time, |
| 204 const base::Time& last_modified_time) { | 256 const base::Time& last_modified_time) { |
| 205 GetNewOperation(path, request_id)->TouchFile( | 257 GetNewOperation(path, request_id)->TouchFile( |
| 206 path, last_access_time, last_modified_time, | 258 path, last_access_time, last_modified_time); |
| 207 base::Bind(&FileSystemDispatcherHost::DidFinish, this, request_id)); | |
| 208 } | 259 } |
| 209 | 260 |
| 210 void FileSystemDispatcherHost::OnCancel( | 261 void FileSystemDispatcherHost::OnCancel( |
| 211 int request_id, | 262 int request_id, |
| 212 int request_id_to_cancel) { | 263 int request_id_to_cancel) { |
| 213 FileSystemOperationInterface* write = operations_.Lookup( | 264 FileSystemOperationInterface* write = operations_.Lookup( |
| 214 request_id_to_cancel); | 265 request_id_to_cancel); |
| 215 if (write) { | 266 if (write) { |
| 216 // The cancel will eventually send both the write failure and the cancel | 267 // The cancel will eventually send both the write failure and the cancel |
| 217 // success. | 268 // success. |
| 218 write->Cancel( | 269 write->Cancel( |
| 219 base::Bind(&FileSystemDispatcherHost::DidCancel, this, request_id)); | 270 BrowserFileSystemCallbackDispatcher::Create(this, request_id)); |
| 220 } else { | 271 } else { |
| 221 // The write already finished; report that we failed to stop it. | 272 // The write already finished; report that we failed to stop it. |
| 222 Send(new FileSystemMsg_DidFail( | 273 Send(new FileSystemMsg_DidFail( |
| 223 request_id, base::PLATFORM_FILE_ERROR_INVALID_OPERATION)); | 274 request_id, base::PLATFORM_FILE_ERROR_INVALID_OPERATION)); |
| 224 } | 275 } |
| 225 } | 276 } |
| 226 | 277 |
| 227 void FileSystemDispatcherHost::OnOpenFile( | 278 void FileSystemDispatcherHost::OnOpenFile( |
| 228 int request_id, const GURL& path, int file_flags) { | 279 int request_id, const GURL& path, int file_flags) { |
| 229 GetNewOperation(path, request_id)->OpenFile( | 280 GetNewOperation(path, request_id)->OpenFile(path, file_flags, peer_handle()); |
| 230 path, file_flags, peer_handle(), | |
| 231 base::Bind(&FileSystemDispatcherHost::DidOpenFile, this, request_id)); | |
| 232 } | 281 } |
| 233 | 282 |
| 234 void FileSystemDispatcherHost::OnWillUpdate(const GURL& path) { | 283 void FileSystemDispatcherHost::OnWillUpdate(const GURL& path) { |
| 235 GURL origin_url; | 284 GURL origin_url; |
| 236 fileapi::FileSystemType type; | 285 fileapi::FileSystemType type; |
| 237 if (!CrackFileSystemURL(path, &origin_url, &type, NULL)) | 286 if (!CrackFileSystemURL(path, &origin_url, &type, NULL)) |
| 238 return; | 287 return; |
| 239 fileapi::FileSystemQuotaUtil* quota_util = context_->GetQuotaUtil(type); | 288 fileapi::FileSystemQuotaUtil* quota_util = context_->GetQuotaUtil(type); |
| 240 if (!quota_util) | 289 if (!quota_util) |
| 241 return; | 290 return; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 269 return; | 318 return; |
| 270 } | 319 } |
| 271 | 320 |
| 272 // This is called only by pepper plugin as of writing to get the | 321 // This is called only by pepper plugin as of writing to get the |
| 273 // underlying platform path to upload a file in the sandboxed filesystem | 322 // underlying platform path to upload a file in the sandboxed filesystem |
| 274 // (e.g. TEMPORARY or PERSISTENT). | 323 // (e.g. TEMPORARY or PERSISTENT). |
| 275 // TODO(kinuko): this hack should go away once appropriate upload-stream | 324 // TODO(kinuko): this hack should go away once appropriate upload-stream |
| 276 // handling based on element types is supported. | 325 // handling based on element types is supported. |
| 277 FileSystemOperation* operation = | 326 FileSystemOperation* operation = |
| 278 context_->CreateFileSystemOperation( | 327 context_->CreateFileSystemOperation( |
| 279 path, | 328 path, scoped_ptr<FileSystemCallbackDispatcher>(NULL), |
| 280 BrowserThread::GetMessageLoopProxyForThread( | 329 BrowserThread::GetMessageLoopProxyForThread( |
| 281 BrowserThread::FILE))->AsFileSystemOperation(); | 330 BrowserThread::FILE))->AsFileSystemOperation(); |
| 282 DCHECK(operation); | 331 DCHECK(operation); |
| 283 operation->SyncGetPlatformPath(path, platform_path); | 332 operation->SyncGetPlatformPath(path, platform_path); |
| 284 } | 333 } |
| 285 | 334 |
| 286 void FileSystemDispatcherHost::DidFinish(int request_id, | |
| 287 base::PlatformFileError result) { | |
| 288 if (result == base::PLATFORM_FILE_OK) | |
| 289 Send(new FileSystemMsg_DidSucceed(request_id)); | |
| 290 else | |
| 291 Send(new FileSystemMsg_DidFail(request_id, result)); | |
| 292 UnregisterOperation(request_id); | |
| 293 } | |
| 294 | |
| 295 void FileSystemDispatcherHost::DidCancel(int request_id, | |
| 296 base::PlatformFileError result) { | |
| 297 if (result == base::PLATFORM_FILE_OK) | |
| 298 Send(new FileSystemMsg_DidSucceed(request_id)); | |
| 299 else | |
| 300 Send(new FileSystemMsg_DidFail(request_id, result)); | |
| 301 // For Cancel we do not create a new operation, so no unregister here. | |
| 302 } | |
| 303 | |
| 304 void FileSystemDispatcherHost::DidGetMetadata( | |
| 305 int request_id, | |
| 306 base::PlatformFileError result, | |
| 307 const base::PlatformFileInfo& info, | |
| 308 const FilePath& platform_path) { | |
| 309 if (result == base::PLATFORM_FILE_OK) | |
| 310 Send(new FileSystemMsg_DidReadMetadata(request_id, info, platform_path)); | |
| 311 else | |
| 312 Send(new FileSystemMsg_DidFail(request_id, result)); | |
| 313 UnregisterOperation(request_id); | |
| 314 } | |
| 315 | |
| 316 void FileSystemDispatcherHost::DidReadDirectory( | |
| 317 int request_id, | |
| 318 base::PlatformFileError result, | |
| 319 const std::vector<base::FileUtilProxy::Entry>& entries, | |
| 320 bool has_more) { | |
| 321 if (result == base::PLATFORM_FILE_OK) | |
| 322 Send(new FileSystemMsg_DidReadDirectory(request_id, entries, has_more)); | |
| 323 else | |
| 324 Send(new FileSystemMsg_DidFail(request_id, result)); | |
| 325 UnregisterOperation(request_id); | |
| 326 } | |
| 327 | |
| 328 void FileSystemDispatcherHost::DidOpenFile(int request_id, | |
| 329 base::PlatformFileError result, | |
| 330 base::PlatformFile file, | |
| 331 base::ProcessHandle peer_handle) { | |
| 332 if (result == base::PLATFORM_FILE_OK) { | |
| 333 IPC::PlatformFileForTransit file_for_transit = | |
| 334 file != base::kInvalidPlatformFileValue ? | |
| 335 IPC::GetFileHandleForProcess(file, peer_handle, true) : | |
| 336 IPC::InvalidPlatformFileForTransit(); | |
| 337 Send(new FileSystemMsg_DidOpenFile(request_id, file_for_transit)); | |
| 338 } else { | |
| 339 Send(new FileSystemMsg_DidFail(request_id, result)); | |
| 340 } | |
| 341 UnregisterOperation(request_id); | |
| 342 } | |
| 343 | |
| 344 void FileSystemDispatcherHost::DidWrite(int request_id, | |
| 345 base::PlatformFileError result, | |
| 346 int64 bytes, | |
| 347 bool complete) { | |
| 348 if (result == base::PLATFORM_FILE_OK) { | |
| 349 Send(new FileSystemMsg_DidWrite(request_id, bytes, complete)); | |
| 350 if (complete) | |
| 351 UnregisterOperation(request_id); | |
| 352 } else { | |
| 353 Send(new FileSystemMsg_DidFail(request_id, result)); | |
| 354 UnregisterOperation(request_id); | |
| 355 } | |
| 356 } | |
| 357 | |
| 358 void FileSystemDispatcherHost::DidOpenFileSystem(int request_id, | |
| 359 base::PlatformFileError result, | |
| 360 const std::string& name, | |
| 361 const GURL& root) { | |
| 362 if (result == base::PLATFORM_FILE_OK) { | |
| 363 DCHECK(root.is_valid()); | |
| 364 Send(new FileSystemMsg_DidOpenFileSystem(request_id, name, root)); | |
| 365 } else { | |
| 366 Send(new FileSystemMsg_DidFail(request_id, result)); | |
| 367 } | |
| 368 // For OpenFileSystem we do not create a new operation, so no unregister here. | |
| 369 } | |
| 370 | |
| 371 FileSystemOperationInterface* FileSystemDispatcherHost::GetNewOperation( | 335 FileSystemOperationInterface* FileSystemDispatcherHost::GetNewOperation( |
| 372 const GURL& target_path, | 336 const GURL& target_path, |
| 373 int request_id) { | 337 int request_id) { |
| 374 FileSystemOperationInterface* operation = | 338 FileSystemOperationInterface* operation = |
| 375 context_->CreateFileSystemOperation( | 339 context_->CreateFileSystemOperation( |
| 376 target_path, | 340 target_path, |
| 341 BrowserFileSystemCallbackDispatcher::Create(this, request_id), |
| 377 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); | 342 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); |
| 378 DCHECK(operation); | 343 DCHECK(operation); |
| 379 operations_.AddWithID(operation, request_id); | 344 operations_.AddWithID(operation, request_id); |
| 380 return operation; | 345 return operation; |
| 381 } | 346 } |
| 382 | 347 |
| 383 void FileSystemDispatcherHost::UnregisterOperation(int request_id) { | 348 void FileSystemDispatcherHost::UnregisterOperation(int request_id) { |
| 384 DCHECK(operations_.Lookup(request_id)); | 349 // For Cancel and OpenFileSystem we do not create an operation. |
| 385 operations_.Remove(request_id); | 350 if (operations_.Lookup(request_id)) |
| 351 operations_.Remove(request_id); |
| 386 } | 352 } |
| OLD | NEW |