| 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" |
| 10 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/platform_file.h" | 13 #include "base/platform_file.h" |
| 13 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 14 #include "base/time.h" | 15 #include "base/time.h" |
| 15 #include "content/common/file_system_messages.h" | 16 #include "content/common/file_system_messages.h" |
| 16 #include "content/public/browser/user_metrics.h" | 17 #include "content/public/browser/user_metrics.h" |
| 17 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
| 18 #include "ipc/ipc_platform_file.h" | 19 #include "ipc/ipc_platform_file.h" |
| 19 #include "net/url_request/url_request_context.h" | 20 #include "net/url_request/url_request_context.h" |
| 20 #include "net/url_request/url_request_context_getter.h" | 21 #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; | |
| 32 using fileapi::FileSystemFileUtil; | 31 using fileapi::FileSystemFileUtil; |
| 33 using fileapi::FileSystemOperation; | 32 using fileapi::FileSystemOperation; |
| 34 using fileapi::FileSystemOperationInterface; | 33 using fileapi::FileSystemOperationInterface; |
| 35 | 34 |
| 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 | |
| 108 FileSystemDispatcherHost::FileSystemDispatcherHost( | 35 FileSystemDispatcherHost::FileSystemDispatcherHost( |
| 109 net::URLRequestContextGetter* request_context_getter, | 36 net::URLRequestContextGetter* request_context_getter, |
| 110 fileapi::FileSystemContext* file_system_context) | 37 fileapi::FileSystemContext* file_system_context) |
| 111 : context_(file_system_context), | 38 : context_(file_system_context), |
| 112 request_context_getter_(request_context_getter), | 39 request_context_getter_(request_context_getter), |
| 113 request_context_(NULL) { | 40 request_context_(NULL) { |
| 114 DCHECK(context_); | 41 DCHECK(context_); |
| 115 DCHECK(request_context_getter_); | 42 DCHECK(request_context_getter_); |
| 116 } | 43 } |
| 117 | 44 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 } | 100 } |
| 174 | 101 |
| 175 void FileSystemDispatcherHost::OnOpen( | 102 void FileSystemDispatcherHost::OnOpen( |
| 176 int request_id, const GURL& origin_url, fileapi::FileSystemType type, | 103 int request_id, const GURL& origin_url, fileapi::FileSystemType type, |
| 177 int64 requested_size, bool create) { | 104 int64 requested_size, bool create) { |
| 178 if (type == fileapi::kFileSystemTypeTemporary) { | 105 if (type == fileapi::kFileSystemTypeTemporary) { |
| 179 content::RecordAction(UserMetricsAction("OpenFileSystemTemporary")); | 106 content::RecordAction(UserMetricsAction("OpenFileSystemTemporary")); |
| 180 } else if (type == fileapi::kFileSystemTypePersistent) { | 107 } else if (type == fileapi::kFileSystemTypePersistent) { |
| 181 content::RecordAction(UserMetricsAction("OpenFileSystemPersistent")); | 108 content::RecordAction(UserMetricsAction("OpenFileSystemPersistent")); |
| 182 } | 109 } |
| 183 context_->OpenFileSystem(origin_url, type, create, | 110 context_->OpenFileSystem(origin_url, type, create, base::Bind( |
| 184 BrowserFileSystemCallbackDispatcher::Create( | 111 &FileSystemDispatcherHost::DidOpenFileSystem, this, request_id)); |
| 185 this, request_id)); | |
| 186 } | 112 } |
| 187 | 113 |
| 188 void FileSystemDispatcherHost::OnMove( | 114 void FileSystemDispatcherHost::OnMove( |
| 189 int request_id, const GURL& src_path, const GURL& dest_path) { | 115 int request_id, const GURL& src_path, const GURL& dest_path) { |
| 190 GetNewOperation(src_path, request_id)->Move(src_path, dest_path); | 116 GetNewOperation(src_path, request_id)->Move( |
| 117 src_path, dest_path, |
| 118 base::Bind(&FileSystemDispatcherHost::DidFinish, this, request_id)); |
| 191 } | 119 } |
| 192 | 120 |
| 193 void FileSystemDispatcherHost::OnCopy( | 121 void FileSystemDispatcherHost::OnCopy( |
| 194 int request_id, const GURL& src_path, const GURL& dest_path) { | 122 int request_id, const GURL& src_path, const GURL& dest_path) { |
| 195 GetNewOperation(src_path, request_id)->Copy(src_path, dest_path); | 123 GetNewOperation(src_path, request_id)->Copy( |
| 124 src_path, dest_path, |
| 125 base::Bind(&FileSystemDispatcherHost::DidFinish, this, request_id)); |
| 196 } | 126 } |
| 197 | 127 |
| 198 void FileSystemDispatcherHost::OnRemove( | 128 void FileSystemDispatcherHost::OnRemove( |
| 199 int request_id, const GURL& path, bool recursive) { | 129 int request_id, const GURL& path, bool recursive) { |
| 200 GetNewOperation(path, request_id)->Remove(path, recursive); | 130 GetNewOperation(path, request_id)->Remove( |
| 131 path, recursive, |
| 132 base::Bind(&FileSystemDispatcherHost::DidFinish, this, request_id)); |
| 201 } | 133 } |
| 202 | 134 |
| 203 void FileSystemDispatcherHost::OnReadMetadata( | 135 void FileSystemDispatcherHost::OnReadMetadata( |
| 204 int request_id, const GURL& path) { | 136 int request_id, const GURL& path) { |
| 205 GetNewOperation(path, request_id)->GetMetadata(path); | 137 GetNewOperation(path, request_id)->GetMetadata( |
| 138 path, |
| 139 base::Bind(&FileSystemDispatcherHost::DidGetMetadata, this, request_id)); |
| 206 } | 140 } |
| 207 | 141 |
| 208 void FileSystemDispatcherHost::OnCreate( | 142 void FileSystemDispatcherHost::OnCreate( |
| 209 int request_id, const GURL& path, bool exclusive, | 143 int request_id, const GURL& path, bool exclusive, |
| 210 bool is_directory, bool recursive) { | 144 bool is_directory, bool recursive) { |
| 211 if (is_directory) | 145 if (is_directory) { |
| 212 GetNewOperation(path, request_id)->CreateDirectory( | 146 GetNewOperation(path, request_id)->CreateDirectory( |
| 213 path, exclusive, recursive); | 147 path, exclusive, recursive, |
| 214 else | 148 base::Bind(&FileSystemDispatcherHost::DidFinish, this, request_id)); |
| 215 GetNewOperation(path, request_id)->CreateFile(path, exclusive); | 149 } else { |
| 150 GetNewOperation(path, request_id)->CreateFile( |
| 151 path, exclusive, |
| 152 base::Bind(&FileSystemDispatcherHost::DidFinish, this, request_id)); |
| 153 } |
| 216 } | 154 } |
| 217 | 155 |
| 218 void FileSystemDispatcherHost::OnExists( | 156 void FileSystemDispatcherHost::OnExists( |
| 219 int request_id, const GURL& path, bool is_directory) { | 157 int request_id, const GURL& path, bool is_directory) { |
| 220 if (is_directory) | 158 if (is_directory) { |
| 221 GetNewOperation(path, request_id)->DirectoryExists(path); | 159 GetNewOperation(path, request_id)->DirectoryExists( |
| 222 else | 160 path, |
| 223 GetNewOperation(path, request_id)->FileExists(path); | 161 base::Bind(&FileSystemDispatcherHost::DidFinish, this, request_id)); |
| 162 } else { |
| 163 GetNewOperation(path, request_id)->FileExists( |
| 164 path, |
| 165 base::Bind(&FileSystemDispatcherHost::DidFinish, this, request_id)); |
| 166 } |
| 224 } | 167 } |
| 225 | 168 |
| 226 void FileSystemDispatcherHost::OnReadDirectory( | 169 void FileSystemDispatcherHost::OnReadDirectory( |
| 227 int request_id, const GURL& path) { | 170 int request_id, const GURL& path) { |
| 228 GetNewOperation(path, request_id)->ReadDirectory(path); | 171 GetNewOperation(path, request_id)->ReadDirectory( |
| 172 path, base::Bind(&FileSystemDispatcherHost::DidReadDirectory, |
| 173 this, request_id)); |
| 229 } | 174 } |
| 230 | 175 |
| 231 void FileSystemDispatcherHost::OnWrite( | 176 void FileSystemDispatcherHost::OnWrite( |
| 232 int request_id, | 177 int request_id, |
| 233 const GURL& path, | 178 const GURL& path, |
| 234 const GURL& blob_url, | 179 const GURL& blob_url, |
| 235 int64 offset) { | 180 int64 offset) { |
| 236 if (!request_context_) { | 181 if (!request_context_) { |
| 237 // We can't write w/o a request context, trying to do so will crash. | 182 // We can't write w/o a request context, trying to do so will crash. |
| 238 NOTREACHED(); | 183 NOTREACHED(); |
| 239 return; | 184 return; |
| 240 } | 185 } |
| 241 GetNewOperation(path, request_id)->Write( | 186 GetNewOperation(path, request_id)->Write( |
| 242 request_context_, path, blob_url, offset); | 187 request_context_, path, blob_url, offset, |
| 188 base::Bind(&FileSystemDispatcherHost::DidWrite, this, request_id)); |
| 243 } | 189 } |
| 244 | 190 |
| 245 void FileSystemDispatcherHost::OnTruncate( | 191 void FileSystemDispatcherHost::OnTruncate( |
| 246 int request_id, | 192 int request_id, |
| 247 const GURL& path, | 193 const GURL& path, |
| 248 int64 length) { | 194 int64 length) { |
| 249 GetNewOperation(path, request_id)->Truncate(path, length); | 195 GetNewOperation(path, request_id)->Truncate( |
| 196 path, length, |
| 197 base::Bind(&FileSystemDispatcherHost::DidFinish, this, request_id)); |
| 250 } | 198 } |
| 251 | 199 |
| 252 void FileSystemDispatcherHost::OnTouchFile( | 200 void FileSystemDispatcherHost::OnTouchFile( |
| 253 int request_id, | 201 int request_id, |
| 254 const GURL& path, | 202 const GURL& path, |
| 255 const base::Time& last_access_time, | 203 const base::Time& last_access_time, |
| 256 const base::Time& last_modified_time) { | 204 const base::Time& last_modified_time) { |
| 257 GetNewOperation(path, request_id)->TouchFile( | 205 GetNewOperation(path, request_id)->TouchFile( |
| 258 path, last_access_time, last_modified_time); | 206 path, last_access_time, last_modified_time, |
| 207 base::Bind(&FileSystemDispatcherHost::DidFinish, this, request_id)); |
| 259 } | 208 } |
| 260 | 209 |
| 261 void FileSystemDispatcherHost::OnCancel( | 210 void FileSystemDispatcherHost::OnCancel( |
| 262 int request_id, | 211 int request_id, |
| 263 int request_id_to_cancel) { | 212 int request_id_to_cancel) { |
| 264 FileSystemOperationInterface* write = operations_.Lookup( | 213 FileSystemOperationInterface* write = operations_.Lookup( |
| 265 request_id_to_cancel); | 214 request_id_to_cancel); |
| 266 if (write) { | 215 if (write) { |
| 267 // The cancel will eventually send both the write failure and the cancel | 216 // The cancel will eventually send both the write failure and the cancel |
| 268 // success. | 217 // success. |
| 269 write->Cancel( | 218 write->Cancel( |
| 270 BrowserFileSystemCallbackDispatcher::Create(this, request_id)); | 219 base::Bind(&FileSystemDispatcherHost::DidCancel, this, request_id)); |
| 271 } else { | 220 } else { |
| 272 // The write already finished; report that we failed to stop it. | 221 // The write already finished; report that we failed to stop it. |
| 273 Send(new FileSystemMsg_DidFail( | 222 Send(new FileSystemMsg_DidFail( |
| 274 request_id, base::PLATFORM_FILE_ERROR_INVALID_OPERATION)); | 223 request_id, base::PLATFORM_FILE_ERROR_INVALID_OPERATION)); |
| 275 } | 224 } |
| 276 } | 225 } |
| 277 | 226 |
| 278 void FileSystemDispatcherHost::OnOpenFile( | 227 void FileSystemDispatcherHost::OnOpenFile( |
| 279 int request_id, const GURL& path, int file_flags) { | 228 int request_id, const GURL& path, int file_flags) { |
| 280 GetNewOperation(path, request_id)->OpenFile(path, file_flags, peer_handle()); | 229 GetNewOperation(path, request_id)->OpenFile( |
| 230 path, file_flags, peer_handle(), |
| 231 base::Bind(&FileSystemDispatcherHost::DidOpenFile, this, request_id)); |
| 281 } | 232 } |
| 282 | 233 |
| 283 void FileSystemDispatcherHost::OnWillUpdate(const GURL& path) { | 234 void FileSystemDispatcherHost::OnWillUpdate(const GURL& path) { |
| 284 GURL origin_url; | 235 GURL origin_url; |
| 285 fileapi::FileSystemType type; | 236 fileapi::FileSystemType type; |
| 286 if (!CrackFileSystemURL(path, &origin_url, &type, NULL)) | 237 if (!CrackFileSystemURL(path, &origin_url, &type, NULL)) |
| 287 return; | 238 return; |
| 288 fileapi::FileSystemQuotaUtil* quota_util = context_->GetQuotaUtil(type); | 239 fileapi::FileSystemQuotaUtil* quota_util = context_->GetQuotaUtil(type); |
| 289 if (!quota_util) | 240 if (!quota_util) |
| 290 return; | 241 return; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 318 return; | 269 return; |
| 319 } | 270 } |
| 320 | 271 |
| 321 // This is called only by pepper plugin as of writing to get the | 272 // This is called only by pepper plugin as of writing to get the |
| 322 // underlying platform path to upload a file in the sandboxed filesystem | 273 // underlying platform path to upload a file in the sandboxed filesystem |
| 323 // (e.g. TEMPORARY or PERSISTENT). | 274 // (e.g. TEMPORARY or PERSISTENT). |
| 324 // TODO(kinuko): this hack should go away once appropriate upload-stream | 275 // TODO(kinuko): this hack should go away once appropriate upload-stream |
| 325 // handling based on element types is supported. | 276 // handling based on element types is supported. |
| 326 FileSystemOperation* operation = | 277 FileSystemOperation* operation = |
| 327 context_->CreateFileSystemOperation( | 278 context_->CreateFileSystemOperation( |
| 328 path, scoped_ptr<FileSystemCallbackDispatcher>(NULL), | 279 path, |
| 329 BrowserThread::GetMessageLoopProxyForThread( | 280 BrowserThread::GetMessageLoopProxyForThread( |
| 330 BrowserThread::FILE))->AsFileSystemOperation(); | 281 BrowserThread::FILE))->AsFileSystemOperation(); |
| 331 DCHECK(operation); | 282 DCHECK(operation); |
| 332 operation->SyncGetPlatformPath(path, platform_path); | 283 operation->SyncGetPlatformPath(path, platform_path); |
| 333 } | 284 } |
| 334 | 285 |
| 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 |
| 335 FileSystemOperationInterface* FileSystemDispatcherHost::GetNewOperation( | 371 FileSystemOperationInterface* FileSystemDispatcherHost::GetNewOperation( |
| 336 const GURL& target_path, | 372 const GURL& target_path, |
| 337 int request_id) { | 373 int request_id) { |
| 338 FileSystemOperationInterface* operation = | 374 FileSystemOperationInterface* operation = |
| 339 context_->CreateFileSystemOperation( | 375 context_->CreateFileSystemOperation( |
| 340 target_path, | 376 target_path, |
| 341 BrowserFileSystemCallbackDispatcher::Create(this, request_id), | |
| 342 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); | 377 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); |
| 343 DCHECK(operation); | 378 DCHECK(operation); |
| 344 operations_.AddWithID(operation, request_id); | 379 operations_.AddWithID(operation, request_id); |
| 345 return operation; | 380 return operation; |
| 346 } | 381 } |
| 347 | 382 |
| 348 void FileSystemDispatcherHost::UnregisterOperation(int request_id) { | 383 void FileSystemDispatcherHost::UnregisterOperation(int request_id) { |
| 349 // For Cancel and OpenFileSystem we do not create an operation. | 384 DCHECK(operations_.Lookup(request_id)); |
| 350 if (operations_.Lookup(request_id)) | 385 operations_.Remove(request_id); |
| 351 operations_.Remove(request_id); | |
| 352 } | 386 } |
| OLD | NEW |