| 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/fileapi/fileapi_message_filter.h" | 5 #include "content/browser/fileapi/fileapi_message_filter.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/bind.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 108 |
| 109 // Close all files that are previously OpenFile()'ed in this process. | 109 // Close all files that are previously OpenFile()'ed in this process. |
| 110 if (!open_filesystem_urls_.empty()) { | 110 if (!open_filesystem_urls_.empty()) { |
| 111 DLOG(INFO) | 111 DLOG(INFO) |
| 112 << "File API: Renderer process shut down before NotifyCloseFile" | 112 << "File API: Renderer process shut down before NotifyCloseFile" |
| 113 << " for " << open_filesystem_urls_.size() << " files opened in PPAPI"; | 113 << " for " << open_filesystem_urls_.size() << " files opened in PPAPI"; |
| 114 } | 114 } |
| 115 for (std::multiset<GURL>::const_iterator iter = | 115 for (std::multiset<GURL>::const_iterator iter = |
| 116 open_filesystem_urls_.begin(); | 116 open_filesystem_urls_.begin(); |
| 117 iter != open_filesystem_urls_.end(); ++iter) { | 117 iter != open_filesystem_urls_.end(); ++iter) { |
| 118 FileSystemURL url(*iter); | 118 FileSystemURL url(context_->CrackURL(*iter)); |
| 119 FileSystemOperation* operation = context_->CreateFileSystemOperation( | 119 FileSystemOperation* operation = context_->CreateFileSystemOperation( |
| 120 url, NULL); | 120 url, NULL); |
| 121 if (operation) | 121 if (operation) |
| 122 operation->NotifyCloseFile(url); | 122 operation->NotifyCloseFile(url); |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 | 125 |
| 126 void FileAPIMessageFilter::OverrideThreadForMessage( | 126 void FileAPIMessageFilter::OverrideThreadForMessage( |
| 127 const IPC::Message& message, | 127 const IPC::Message& message, |
| 128 BrowserThread::ID* thread) { | 128 BrowserThread::ID* thread) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 fileapi::FileSystemType type) { | 200 fileapi::FileSystemType type) { |
| 201 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 201 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 202 context_->DeleteFileSystem(origin_url, type, base::Bind( | 202 context_->DeleteFileSystem(origin_url, type, base::Bind( |
| 203 &FileAPIMessageFilter::DidDeleteFileSystem, this, request_id)); | 203 &FileAPIMessageFilter::DidDeleteFileSystem, this, request_id)); |
| 204 } | 204 } |
| 205 | 205 |
| 206 void FileAPIMessageFilter::OnMove( | 206 void FileAPIMessageFilter::OnMove( |
| 207 int request_id, const GURL& src_path, const GURL& dest_path) { | 207 int request_id, const GURL& src_path, const GURL& dest_path) { |
| 208 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 208 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 209 base::PlatformFileError error; | 209 base::PlatformFileError error; |
| 210 FileSystemURL src_url(src_path); | 210 FileSystemURL src_url(context_->CrackURL(src_path)); |
| 211 FileSystemURL dest_url(dest_path); | 211 FileSystemURL dest_url(context_->CrackURL(dest_path)); |
| 212 const int src_permissions = | 212 const int src_permissions = |
| 213 fileapi::kReadFilePermissions | fileapi::kWriteFilePermissions; | 213 fileapi::kReadFilePermissions | fileapi::kWriteFilePermissions; |
| 214 if (!HasPermissionsForFile(src_url, src_permissions, &error) || | 214 if (!HasPermissionsForFile(src_url, src_permissions, &error) || |
| 215 !HasPermissionsForFile( | 215 !HasPermissionsForFile( |
| 216 dest_url, fileapi::kCreateFilePermissions, &error)) { | 216 dest_url, fileapi::kCreateFilePermissions, &error)) { |
| 217 Send(new FileSystemMsg_DidFail(request_id, error)); | 217 Send(new FileSystemMsg_DidFail(request_id, error)); |
| 218 return; | 218 return; |
| 219 } | 219 } |
| 220 | 220 |
| 221 FileSystemOperation* operation = GetNewOperation(dest_url, request_id); | 221 FileSystemOperation* operation = GetNewOperation(dest_url, request_id); |
| 222 if (!operation) | 222 if (!operation) |
| 223 return; | 223 return; |
| 224 operation->Move( | 224 operation->Move( |
| 225 src_url, dest_url, | 225 src_url, dest_url, |
| 226 base::Bind(&FileAPIMessageFilter::DidFinish, this, request_id)); | 226 base::Bind(&FileAPIMessageFilter::DidFinish, this, request_id)); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void FileAPIMessageFilter::OnCopy( | 229 void FileAPIMessageFilter::OnCopy( |
| 230 int request_id, const GURL& src_path, const GURL& dest_path) { | 230 int request_id, const GURL& src_path, const GURL& dest_path) { |
| 231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 232 base::PlatformFileError error; | 232 base::PlatformFileError error; |
| 233 FileSystemURL src_url(src_path); | 233 FileSystemURL src_url(context_->CrackURL(src_path)); |
| 234 FileSystemURL dest_url(dest_path); | 234 FileSystemURL dest_url(context_->CrackURL(dest_path)); |
| 235 if (!HasPermissionsForFile(src_url, fileapi::kReadFilePermissions, &error) || | 235 if (!HasPermissionsForFile(src_url, fileapi::kReadFilePermissions, &error) || |
| 236 !HasPermissionsForFile( | 236 !HasPermissionsForFile( |
| 237 dest_url, fileapi::kCreateFilePermissions, &error)) { | 237 dest_url, fileapi::kCreateFilePermissions, &error)) { |
| 238 Send(new FileSystemMsg_DidFail(request_id, error)); | 238 Send(new FileSystemMsg_DidFail(request_id, error)); |
| 239 return; | 239 return; |
| 240 } | 240 } |
| 241 | 241 |
| 242 FileSystemOperation* operation = GetNewOperation(dest_url, request_id); | 242 FileSystemOperation* operation = GetNewOperation(dest_url, request_id); |
| 243 if (!operation) | 243 if (!operation) |
| 244 return; | 244 return; |
| 245 operation->Copy( | 245 operation->Copy( |
| 246 src_url, dest_url, | 246 src_url, dest_url, |
| 247 base::Bind(&FileAPIMessageFilter::DidFinish, this, request_id)); | 247 base::Bind(&FileAPIMessageFilter::DidFinish, this, request_id)); |
| 248 } | 248 } |
| 249 | 249 |
| 250 void FileAPIMessageFilter::OnRemove( | 250 void FileAPIMessageFilter::OnRemove( |
| 251 int request_id, const GURL& path, bool recursive) { | 251 int request_id, const GURL& path, bool recursive) { |
| 252 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 252 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 253 base::PlatformFileError error; | 253 base::PlatformFileError error; |
| 254 FileSystemURL url(path); | 254 FileSystemURL url(context_->CrackURL(path)); |
| 255 if (!HasPermissionsForFile(url, fileapi::kWriteFilePermissions, &error)) { | 255 if (!HasPermissionsForFile(url, fileapi::kWriteFilePermissions, &error)) { |
| 256 Send(new FileSystemMsg_DidFail(request_id, error)); | 256 Send(new FileSystemMsg_DidFail(request_id, error)); |
| 257 return; | 257 return; |
| 258 } | 258 } |
| 259 | 259 |
| 260 FileSystemOperation* operation = GetNewOperation(url, request_id); | 260 FileSystemOperation* operation = GetNewOperation(url, request_id); |
| 261 if (!operation) | 261 if (!operation) |
| 262 return; | 262 return; |
| 263 operation->Remove( | 263 operation->Remove( |
| 264 url, recursive, | 264 url, recursive, |
| 265 base::Bind(&FileAPIMessageFilter::DidFinish, this, request_id)); | 265 base::Bind(&FileAPIMessageFilter::DidFinish, this, request_id)); |
| 266 } | 266 } |
| 267 | 267 |
| 268 void FileAPIMessageFilter::OnReadMetadata( | 268 void FileAPIMessageFilter::OnReadMetadata( |
| 269 int request_id, const GURL& path) { | 269 int request_id, const GURL& path) { |
| 270 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 270 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 271 base::PlatformFileError error; | 271 base::PlatformFileError error; |
| 272 FileSystemURL url(path); | 272 FileSystemURL url(context_->CrackURL(path)); |
| 273 if (!HasPermissionsForFile(url, fileapi::kReadFilePermissions, &error)) { | 273 if (!HasPermissionsForFile(url, fileapi::kReadFilePermissions, &error)) { |
| 274 Send(new FileSystemMsg_DidFail(request_id, error)); | 274 Send(new FileSystemMsg_DidFail(request_id, error)); |
| 275 return; | 275 return; |
| 276 } | 276 } |
| 277 | 277 |
| 278 FileSystemOperation* operation = GetNewOperation(url, request_id); | 278 FileSystemOperation* operation = GetNewOperation(url, request_id); |
| 279 if (!operation) | 279 if (!operation) |
| 280 return; | 280 return; |
| 281 operation->GetMetadata( | 281 operation->GetMetadata( |
| 282 url, | 282 url, |
| 283 base::Bind(&FileAPIMessageFilter::DidGetMetadata, this, request_id)); | 283 base::Bind(&FileAPIMessageFilter::DidGetMetadata, this, request_id)); |
| 284 } | 284 } |
| 285 | 285 |
| 286 void FileAPIMessageFilter::OnCreate( | 286 void FileAPIMessageFilter::OnCreate( |
| 287 int request_id, const GURL& path, bool exclusive, | 287 int request_id, const GURL& path, bool exclusive, |
| 288 bool is_directory, bool recursive) { | 288 bool is_directory, bool recursive) { |
| 289 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 289 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 290 base::PlatformFileError error; | 290 base::PlatformFileError error; |
| 291 FileSystemURL url(path); | 291 FileSystemURL url(context_->CrackURL(path)); |
| 292 if (!HasPermissionsForFile(url, fileapi::kCreateFilePermissions, &error)) { | 292 if (!HasPermissionsForFile(url, fileapi::kCreateFilePermissions, &error)) { |
| 293 Send(new FileSystemMsg_DidFail(request_id, error)); | 293 Send(new FileSystemMsg_DidFail(request_id, error)); |
| 294 return; | 294 return; |
| 295 } | 295 } |
| 296 | 296 |
| 297 FileSystemOperation* operation = GetNewOperation(url, request_id); | 297 FileSystemOperation* operation = GetNewOperation(url, request_id); |
| 298 if (!operation) | 298 if (!operation) |
| 299 return; | 299 return; |
| 300 if (is_directory) { | 300 if (is_directory) { |
| 301 operation->CreateDirectory( | 301 operation->CreateDirectory( |
| 302 url, exclusive, recursive, | 302 url, exclusive, recursive, |
| 303 base::Bind(&FileAPIMessageFilter::DidFinish, this, request_id)); | 303 base::Bind(&FileAPIMessageFilter::DidFinish, this, request_id)); |
| 304 } else { | 304 } else { |
| 305 operation->CreateFile( | 305 operation->CreateFile( |
| 306 url, exclusive, | 306 url, exclusive, |
| 307 base::Bind(&FileAPIMessageFilter::DidFinish, this, request_id)); | 307 base::Bind(&FileAPIMessageFilter::DidFinish, this, request_id)); |
| 308 } | 308 } |
| 309 } | 309 } |
| 310 | 310 |
| 311 void FileAPIMessageFilter::OnExists( | 311 void FileAPIMessageFilter::OnExists( |
| 312 int request_id, const GURL& path, bool is_directory) { | 312 int request_id, const GURL& path, bool is_directory) { |
| 313 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 313 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 314 base::PlatformFileError error; | 314 base::PlatformFileError error; |
| 315 FileSystemURL url(path); | 315 FileSystemURL url(context_->CrackURL(path)); |
| 316 if (!HasPermissionsForFile(url, fileapi::kReadFilePermissions, &error)) { | 316 if (!HasPermissionsForFile(url, fileapi::kReadFilePermissions, &error)) { |
| 317 Send(new FileSystemMsg_DidFail(request_id, error)); | 317 Send(new FileSystemMsg_DidFail(request_id, error)); |
| 318 return; | 318 return; |
| 319 } | 319 } |
| 320 | 320 |
| 321 FileSystemOperation* operation = GetNewOperation(url, request_id); | 321 FileSystemOperation* operation = GetNewOperation(url, request_id); |
| 322 if (!operation) | 322 if (!operation) |
| 323 return; | 323 return; |
| 324 if (is_directory) { | 324 if (is_directory) { |
| 325 operation->DirectoryExists( | 325 operation->DirectoryExists( |
| 326 url, | 326 url, |
| 327 base::Bind(&FileAPIMessageFilter::DidFinish, this, request_id)); | 327 base::Bind(&FileAPIMessageFilter::DidFinish, this, request_id)); |
| 328 } else { | 328 } else { |
| 329 operation->FileExists( | 329 operation->FileExists( |
| 330 url, | 330 url, |
| 331 base::Bind(&FileAPIMessageFilter::DidFinish, this, request_id)); | 331 base::Bind(&FileAPIMessageFilter::DidFinish, this, request_id)); |
| 332 } | 332 } |
| 333 } | 333 } |
| 334 | 334 |
| 335 void FileAPIMessageFilter::OnReadDirectory( | 335 void FileAPIMessageFilter::OnReadDirectory( |
| 336 int request_id, const GURL& path) { | 336 int request_id, const GURL& path) { |
| 337 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 337 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 338 base::PlatformFileError error; | 338 base::PlatformFileError error; |
| 339 FileSystemURL url(path); | 339 FileSystemURL url(context_->CrackURL(path)); |
| 340 if (!HasPermissionsForFile(url, fileapi::kReadFilePermissions, &error)) { | 340 if (!HasPermissionsForFile(url, fileapi::kReadFilePermissions, &error)) { |
| 341 Send(new FileSystemMsg_DidFail(request_id, error)); | 341 Send(new FileSystemMsg_DidFail(request_id, error)); |
| 342 return; | 342 return; |
| 343 } | 343 } |
| 344 | 344 |
| 345 FileSystemOperation* operation = GetNewOperation(url, request_id); | 345 FileSystemOperation* operation = GetNewOperation(url, request_id); |
| 346 if (!operation) | 346 if (!operation) |
| 347 return; | 347 return; |
| 348 operation->ReadDirectory( | 348 operation->ReadDirectory( |
| 349 url, base::Bind(&FileAPIMessageFilter::DidReadDirectory, | 349 url, base::Bind(&FileAPIMessageFilter::DidReadDirectory, |
| 350 this, request_id)); | 350 this, request_id)); |
| 351 } | 351 } |
| 352 | 352 |
| 353 void FileAPIMessageFilter::OnWrite( | 353 void FileAPIMessageFilter::OnWrite( |
| 354 int request_id, | 354 int request_id, |
| 355 const GURL& path, | 355 const GURL& path, |
| 356 const GURL& blob_url, | 356 const GURL& blob_url, |
| 357 int64 offset) { | 357 int64 offset) { |
| 358 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 358 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 359 if (!request_context_) { | 359 if (!request_context_) { |
| 360 // We can't write w/o a request context, trying to do so will crash. | 360 // We can't write w/o a request context, trying to do so will crash. |
| 361 NOTREACHED(); | 361 NOTREACHED(); |
| 362 return; | 362 return; |
| 363 } | 363 } |
| 364 | 364 |
| 365 FileSystemURL url(path); | 365 FileSystemURL url(context_->CrackURL(path)); |
| 366 base::PlatformFileError error; | 366 base::PlatformFileError error; |
| 367 if (!HasPermissionsForFile(url, fileapi::kWriteFilePermissions, &error)) { | 367 if (!HasPermissionsForFile(url, fileapi::kWriteFilePermissions, &error)) { |
| 368 Send(new FileSystemMsg_DidFail(request_id, error)); | 368 Send(new FileSystemMsg_DidFail(request_id, error)); |
| 369 return; | 369 return; |
| 370 } | 370 } |
| 371 | 371 |
| 372 FileSystemOperation* operation = GetNewOperation(url, request_id); | 372 FileSystemOperation* operation = GetNewOperation(url, request_id); |
| 373 if (!operation) | 373 if (!operation) |
| 374 return; | 374 return; |
| 375 operation->Write( | 375 operation->Write( |
| 376 request_context_, url, blob_url, offset, | 376 request_context_, url, blob_url, offset, |
| 377 base::Bind(&FileAPIMessageFilter::DidWrite, this, request_id)); | 377 base::Bind(&FileAPIMessageFilter::DidWrite, this, request_id)); |
| 378 } | 378 } |
| 379 | 379 |
| 380 void FileAPIMessageFilter::OnTruncate( | 380 void FileAPIMessageFilter::OnTruncate( |
| 381 int request_id, | 381 int request_id, |
| 382 const GURL& path, | 382 const GURL& path, |
| 383 int64 length) { | 383 int64 length) { |
| 384 base::PlatformFileError error; | 384 base::PlatformFileError error; |
| 385 FileSystemURL url(path); | 385 FileSystemURL url(context_->CrackURL(path)); |
| 386 if (!HasPermissionsForFile(url, fileapi::kWriteFilePermissions, &error)) { | 386 if (!HasPermissionsForFile(url, fileapi::kWriteFilePermissions, &error)) { |
| 387 Send(new FileSystemMsg_DidFail(request_id, error)); | 387 Send(new FileSystemMsg_DidFail(request_id, error)); |
| 388 return; | 388 return; |
| 389 } | 389 } |
| 390 | 390 |
| 391 FileSystemOperation* operation = GetNewOperation(url, request_id); | 391 FileSystemOperation* operation = GetNewOperation(url, request_id); |
| 392 if (!operation) | 392 if (!operation) |
| 393 return; | 393 return; |
| 394 operation->Truncate( | 394 operation->Truncate( |
| 395 url, length, | 395 url, length, |
| 396 base::Bind(&FileAPIMessageFilter::DidFinish, this, request_id)); | 396 base::Bind(&FileAPIMessageFilter::DidFinish, this, request_id)); |
| 397 } | 397 } |
| 398 | 398 |
| 399 void FileAPIMessageFilter::OnTouchFile( | 399 void FileAPIMessageFilter::OnTouchFile( |
| 400 int request_id, | 400 int request_id, |
| 401 const GURL& path, | 401 const GURL& path, |
| 402 const base::Time& last_access_time, | 402 const base::Time& last_access_time, |
| 403 const base::Time& last_modified_time) { | 403 const base::Time& last_modified_time) { |
| 404 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 404 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 405 FileSystemURL url(path); | 405 FileSystemURL url(context_->CrackURL(path)); |
| 406 base::PlatformFileError error; | 406 base::PlatformFileError error; |
| 407 if (!HasPermissionsForFile(url, fileapi::kCreateFilePermissions, &error)) { | 407 if (!HasPermissionsForFile(url, fileapi::kCreateFilePermissions, &error)) { |
| 408 Send(new FileSystemMsg_DidFail(request_id, error)); | 408 Send(new FileSystemMsg_DidFail(request_id, error)); |
| 409 return; | 409 return; |
| 410 } | 410 } |
| 411 | 411 |
| 412 FileSystemOperation* operation = GetNewOperation(url, request_id); | 412 FileSystemOperation* operation = GetNewOperation(url, request_id); |
| 413 if (!operation) | 413 if (!operation) |
| 414 return; | 414 return; |
| 415 operation->TouchFile( | 415 operation->TouchFile( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 433 request_id, base::PLATFORM_FILE_ERROR_INVALID_OPERATION)); | 433 request_id, base::PLATFORM_FILE_ERROR_INVALID_OPERATION)); |
| 434 } | 434 } |
| 435 } | 435 } |
| 436 | 436 |
| 437 void FileAPIMessageFilter::OnOpenFile( | 437 void FileAPIMessageFilter::OnOpenFile( |
| 438 int request_id, const GURL& path, int file_flags) { | 438 int request_id, const GURL& path, int file_flags) { |
| 439 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 439 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 440 base::PlatformFileError error; | 440 base::PlatformFileError error; |
| 441 const int open_permissions = base::PLATFORM_FILE_OPEN | | 441 const int open_permissions = base::PLATFORM_FILE_OPEN | |
| 442 (file_flags & fileapi::kOpenFilePermissions); | 442 (file_flags & fileapi::kOpenFilePermissions); |
| 443 FileSystemURL url(path); | 443 FileSystemURL url(context_->CrackURL(path)); |
| 444 if (!HasPermissionsForFile(url, open_permissions, &error)) { | 444 if (!HasPermissionsForFile(url, open_permissions, &error)) { |
| 445 Send(new FileSystemMsg_DidFail(request_id, error)); | 445 Send(new FileSystemMsg_DidFail(request_id, error)); |
| 446 return; | 446 return; |
| 447 } | 447 } |
| 448 | 448 |
| 449 FileSystemOperation* operation = GetNewOperation(url, request_id); | 449 FileSystemOperation* operation = GetNewOperation(url, request_id); |
| 450 if (!operation) | 450 if (!operation) |
| 451 return; | 451 return; |
| 452 operation->OpenFile( | 452 operation->OpenFile( |
| 453 url, file_flags, peer_handle(), | 453 url, file_flags, peer_handle(), |
| 454 base::Bind(&FileAPIMessageFilter::DidOpenFile, this, request_id, path)); | 454 base::Bind(&FileAPIMessageFilter::DidOpenFile, this, request_id, path)); |
| 455 } | 455 } |
| 456 | 456 |
| 457 void FileAPIMessageFilter::OnNotifyCloseFile(const GURL& path) { | 457 void FileAPIMessageFilter::OnNotifyCloseFile(const GURL& path) { |
| 458 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 458 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 459 | 459 |
| 460 // Remove |path| from the set of opened urls. It must only be called for a URL | 460 // Remove |path| from the set of opened urls. It must only be called for a URL |
| 461 // that is successfully opened and enrolled in DidOpenFile. | 461 // that is successfully opened and enrolled in DidOpenFile. |
| 462 std::multiset<GURL>::iterator iter = open_filesystem_urls_.find(path); | 462 std::multiset<GURL>::iterator iter = open_filesystem_urls_.find(path); |
| 463 DCHECK(iter != open_filesystem_urls_.end()); | 463 DCHECK(iter != open_filesystem_urls_.end()); |
| 464 open_filesystem_urls_.erase(iter); | 464 open_filesystem_urls_.erase(iter); |
| 465 | 465 |
| 466 FileSystemURL url(path); | 466 FileSystemURL url(context_->CrackURL(path)); |
| 467 | 467 |
| 468 // Do not use GetNewOperation() here, because NotifyCloseFile is a one-way | 468 // Do not use GetNewOperation() here, because NotifyCloseFile is a one-way |
| 469 // operation that does not have request_id by which we respond back. | 469 // operation that does not have request_id by which we respond back. |
| 470 FileSystemOperation* operation = context_->CreateFileSystemOperation( | 470 FileSystemOperation* operation = context_->CreateFileSystemOperation( |
| 471 url, NULL); | 471 url, NULL); |
| 472 if (operation) | 472 if (operation) |
| 473 operation->NotifyCloseFile(url); | 473 operation->NotifyCloseFile(url); |
| 474 } | 474 } |
| 475 | 475 |
| 476 void FileAPIMessageFilter::OnWillUpdate(const GURL& path) { | 476 void FileAPIMessageFilter::OnWillUpdate(const GURL& path) { |
| 477 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 477 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 478 FileSystemURL url(path); | 478 FileSystemURL url(context_->CrackURL(path)); |
| 479 if (!url.is_valid()) | 479 if (!url.is_valid()) |
| 480 return; | 480 return; |
| 481 const UpdateObserverList* observers = | 481 const UpdateObserverList* observers = |
| 482 context_->GetUpdateObservers(url.type()); | 482 context_->GetUpdateObservers(url.type()); |
| 483 if (!observers) | 483 if (!observers) |
| 484 return; | 484 return; |
| 485 observers->Notify(&FileUpdateObserver::OnStartUpdate, MakeTuple(url)); | 485 observers->Notify(&FileUpdateObserver::OnStartUpdate, MakeTuple(url)); |
| 486 } | 486 } |
| 487 | 487 |
| 488 void FileAPIMessageFilter::OnDidUpdate(const GURL& path, int64 delta) { | 488 void FileAPIMessageFilter::OnDidUpdate(const GURL& path, int64 delta) { |
| 489 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 489 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 490 FileSystemURL url(path); | 490 FileSystemURL url(context_->CrackURL(path)); |
| 491 if (!url.is_valid()) | 491 if (!url.is_valid()) |
| 492 return; | 492 return; |
| 493 const UpdateObserverList* observers = | 493 const UpdateObserverList* observers = |
| 494 context_->GetUpdateObservers(url.type()); | 494 context_->GetUpdateObservers(url.type()); |
| 495 if (!observers) | 495 if (!observers) |
| 496 return; | 496 return; |
| 497 observers->Notify(&FileUpdateObserver::OnUpdate, MakeTuple(url, delta)); | 497 observers->Notify(&FileUpdateObserver::OnUpdate, MakeTuple(url, delta)); |
| 498 observers->Notify(&FileUpdateObserver::OnEndUpdate, MakeTuple(url)); | 498 observers->Notify(&FileUpdateObserver::OnEndUpdate, MakeTuple(url)); |
| 499 } | 499 } |
| 500 | 500 |
| 501 void FileAPIMessageFilter::OnSyncGetPlatformPath( | 501 void FileAPIMessageFilter::OnSyncGetPlatformPath( |
| 502 const GURL& path, FilePath* platform_path) { | 502 const GURL& path, FilePath* platform_path) { |
| 503 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 503 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 504 DCHECK(platform_path); | 504 DCHECK(platform_path); |
| 505 *platform_path = FilePath(); | 505 *platform_path = FilePath(); |
| 506 FileSystemURL url(path); | 506 FileSystemURL url(context_->CrackURL(path)); |
| 507 if (!url.is_valid()) | 507 if (!url.is_valid()) |
| 508 return; | 508 return; |
| 509 | 509 |
| 510 // Make sure if this file is ok to be read (in the current architecture | 510 // Make sure if this file is ok to be read (in the current architecture |
| 511 // which means roughly same as the renderer is allowed to get the platform | 511 // which means roughly same as the renderer is allowed to get the platform |
| 512 // path to the file). | 512 // path to the file). |
| 513 base::PlatformFileError error; | 513 base::PlatformFileError error; |
| 514 if (!HasPermissionsForFile(url, fileapi::kReadFilePermissions, &error)) | 514 if (!HasPermissionsForFile(url, fileapi::kReadFilePermissions, &error)) |
| 515 return; | 515 return; |
| 516 | 516 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 534 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( | 534 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( |
| 535 process_id_, *platform_path)) { | 535 process_id_, *platform_path)) { |
| 536 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( | 536 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( |
| 537 process_id_, *platform_path); | 537 process_id_, *platform_path); |
| 538 } | 538 } |
| 539 } | 539 } |
| 540 | 540 |
| 541 void FileAPIMessageFilter::OnCreateSnapshotFile( | 541 void FileAPIMessageFilter::OnCreateSnapshotFile( |
| 542 int request_id, const GURL& blob_url, const GURL& path) { | 542 int request_id, const GURL& blob_url, const GURL& path) { |
| 543 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 543 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 544 FileSystemURL url(path); | 544 FileSystemURL url(context_->CrackURL(path)); |
| 545 base::Callback<void(const FilePath&)> register_file_callback = | 545 base::Callback<void(const FilePath&)> register_file_callback = |
| 546 base::Bind(&FileAPIMessageFilter::RegisterFileAsBlob, | 546 base::Bind(&FileAPIMessageFilter::RegisterFileAsBlob, |
| 547 this, blob_url, url); | 547 this, blob_url, url); |
| 548 | 548 |
| 549 // Make sure if this file can be read by the renderer as this is | 549 // Make sure if this file can be read by the renderer as this is |
| 550 // called when the renderer is about to create a new File object | 550 // called when the renderer is about to create a new File object |
| 551 // (for reading the file). | 551 // (for reading the file). |
| 552 base::PlatformFileError error; | 552 base::PlatformFileError error; |
| 553 if (!HasPermissionsForFile(url, fileapi::kReadFilePermissions, &error)) { | 553 if (!HasPermissionsForFile(url, fileapi::kReadFilePermissions, &error)) { |
| 554 Send(new FileSystemMsg_DidFail(request_id, error)); | 554 Send(new FileSystemMsg_DidFail(request_id, error)); |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 Send(new FileSystemMsg_DidFail(request_id, error_code)); | 865 Send(new FileSystemMsg_DidFail(request_id, error_code)); |
| 866 return NULL; | 866 return NULL; |
| 867 } | 867 } |
| 868 | 868 |
| 869 DCHECK(operation); | 869 DCHECK(operation); |
| 870 operations_.AddWithID(operation, request_id); | 870 operations_.AddWithID(operation, request_id); |
| 871 return operation; | 871 return operation; |
| 872 } | 872 } |
| 873 | 873 |
| 874 } // namespace content | 874 } // namespace content |
| OLD | NEW |