Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "content/browser/indexed_db/indexed_db_backing_store.h" | 5 #include "content/browser/indexed_db/indexed_db_backing_store.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 2342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2353 bytes_written_)); | 2353 bytes_written_)); |
| 2354 } | 2354 } |
| 2355 } | 2355 } |
| 2356 | 2356 |
| 2357 void WriteBlobToFileOnIOThread(const FilePath& file_path, | 2357 void WriteBlobToFileOnIOThread(const FilePath& file_path, |
| 2358 const GURL& blob_url, | 2358 const GURL& blob_url, |
| 2359 const base::Time& last_modified, | 2359 const base::Time& last_modified, |
| 2360 net::URLRequestContext* request_context) { | 2360 net::URLRequestContext* request_context) { |
| 2361 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 2361 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 2362 scoped_ptr<storage::FileStreamWriter> writer( | 2362 scoped_ptr<storage::FileStreamWriter> writer( |
| 2363 storage::FileStreamWriter::CreateForLocalFile( | 2363 storage::FileStreamWriter::CreateForLocalFile(task_runner_.get(), |
| 2364 task_runner_.get(), | 2364 file_path, 0)); |
| 2365 file_path, | |
| 2366 0, | |
| 2367 storage::FileStreamWriter::CREATE_NEW_FILE)); | |
| 2368 scoped_ptr<FileWriterDelegate> delegate(new FileWriterDelegate( | 2365 scoped_ptr<FileWriterDelegate> delegate(new FileWriterDelegate( |
| 2369 writer.Pass(), storage::FlushPolicy::FLUSH_ON_COMPLETION)); | 2366 writer.Pass(), storage::FlushPolicy::FLUSH_ON_COMPLETION)); |
| 2370 | 2367 |
| 2371 DCHECK(blob_url.is_valid()); | 2368 DCHECK(blob_url.is_valid()); |
| 2372 scoped_ptr<net::URLRequest> blob_request(request_context->CreateRequest( | 2369 scoped_ptr<net::URLRequest> blob_request(request_context->CreateRequest( |
| 2373 blob_url, net::DEFAULT_PRIORITY, delegate.get(), NULL)); | 2370 blob_url, net::DEFAULT_PRIORITY, delegate.get(), NULL)); |
| 2374 | 2371 |
| 2375 this->file_path_ = file_path; | 2372 this->file_path_ = file_path; |
| 2376 this->last_modified_ = last_modified; | 2373 this->last_modified_ = last_modified; |
| 2377 | 2374 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2449 task_runner_->PostTask( | 2446 task_runner_->PostTask( |
| 2450 FROM_HERE, | 2447 FROM_HERE, |
| 2451 base::Bind(&Transaction::ChainedBlobWriter::ReportWriteCompletion, | 2448 base::Bind(&Transaction::ChainedBlobWriter::ReportWriteCompletion, |
| 2452 chained_blob_writer, | 2449 chained_blob_writer, |
| 2453 true, | 2450 true, |
| 2454 info.size)); | 2451 info.size)); |
| 2455 } else { | 2452 } else { |
| 2456 DCHECK(descriptor.url().is_valid()); | 2453 DCHECK(descriptor.url().is_valid()); |
| 2457 scoped_refptr<LocalWriteClosure> write_closure( | 2454 scoped_refptr<LocalWriteClosure> write_closure( |
| 2458 new LocalWriteClosure(chained_blob_writer, task_runner_.get())); | 2455 new LocalWriteClosure(chained_blob_writer, task_runner_.get())); |
| 2456 { | |
| 2457 // FileStreamWriter needs an existing file, so create one now. | |
| 2458 base::File file(path, | |
|
jsbell
2015/03/03 01:01:48
Should we do this in WriteBlobToFileOnIOThread ins
cmumford
2015/03/03 22:26:09
Can't do file I/O on that thread - only reason why
| |
| 2459 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); | |
|
michaeln
2015/03/03 00:02:51
nit: ditto file.Close()
cmumford
2015/03/03 22:26:09
Done.
| |
| 2460 } | |
| 2459 content::BrowserThread::PostTask( | 2461 content::BrowserThread::PostTask( |
| 2460 content::BrowserThread::IO, | 2462 content::BrowserThread::IO, |
| 2461 FROM_HERE, | 2463 FROM_HERE, |
| 2462 base::Bind(&LocalWriteClosure::WriteBlobToFileOnIOThread, | 2464 base::Bind(&LocalWriteClosure::WriteBlobToFileOnIOThread, |
| 2463 write_closure.get(), | 2465 write_closure.get(), |
| 2464 path, | 2466 path, |
| 2465 descriptor.url(), | 2467 descriptor.url(), |
| 2466 descriptor.last_modified(), | 2468 descriptor.last_modified(), |
| 2467 request_context_)); | 2469 request_context_)); |
| 2468 } | 2470 } |
| (...skipping 1935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4404 | 4406 |
| 4405 IndexedDBBackingStore::Transaction::WriteDescriptor::WriteDescriptor( | 4407 IndexedDBBackingStore::Transaction::WriteDescriptor::WriteDescriptor( |
| 4406 const WriteDescriptor& other) = default; | 4408 const WriteDescriptor& other) = default; |
| 4407 IndexedDBBackingStore::Transaction::WriteDescriptor::~WriteDescriptor() = | 4409 IndexedDBBackingStore::Transaction::WriteDescriptor::~WriteDescriptor() = |
| 4408 default; | 4410 default; |
| 4409 IndexedDBBackingStore::Transaction::WriteDescriptor& | 4411 IndexedDBBackingStore::Transaction::WriteDescriptor& |
| 4410 IndexedDBBackingStore::Transaction::WriteDescriptor:: | 4412 IndexedDBBackingStore::Transaction::WriteDescriptor:: |
| 4411 operator=(const WriteDescriptor& other) = default; | 4413 operator=(const WriteDescriptor& other) = default; |
| 4412 | 4414 |
| 4413 } // namespace content | 4415 } // namespace content |
| OLD | NEW |