| 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 base::PlatformFileError result, | 719 base::PlatformFileError result, |
| 720 const std::string& fs_name, | 720 const std::string& fs_name, |
| 721 const GURL& root) { | 721 const GURL& root) { |
| 722 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 722 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 723 root_ = root.spec(); | 723 root_ = root.spec(); |
| 724 CHECK(BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( | 724 CHECK(BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( |
| 725 &HTML5FileWriter::CreateFile, base::Unretained(this)))); | 725 &HTML5FileWriter::CreateFile, base::Unretained(this)))); |
| 726 } | 726 } |
| 727 | 727 |
| 728 fileapi::FileSystemOperation* operation() { | 728 fileapi::FileSystemOperation* operation() { |
| 729 return fs_->CreateFileSystemOperation( | 729 return fs_->CreateFileSystemOperation(fs_->CrackURL(GURL(root_)), NULL); |
| 730 fileapi::FileSystemURL(GURL(root_)), NULL); | |
| 731 } | 730 } |
| 732 | 731 |
| 733 void CreateFile() { | 732 void CreateFile() { |
| 734 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 733 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 735 operation()->CreateFile(fileapi::FileSystemURL(GURL(root_ + filename_)), | 734 operation()->CreateFile(fs_->CrackURL(GURL(root_ + filename_)), |
| 736 kExclusive, base::Bind( | 735 kExclusive, base::Bind( |
| 737 &HTML5FileWriter::CreateFileCallback, base::Unretained(this))); | 736 &HTML5FileWriter::CreateFileCallback, base::Unretained(this))); |
| 738 } | 737 } |
| 739 | 738 |
| 740 void CreateFileCallback(base::PlatformFileError result) { | 739 void CreateFileCallback(base::PlatformFileError result) { |
| 741 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 740 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 742 CHECK_EQ(base::PLATFORM_FILE_OK, result); | 741 CHECK_EQ(base::PLATFORM_FILE_OK, result); |
| 743 blob_data_->AppendData(payload_); | 742 blob_data_->AppendData(payload_); |
| 744 url_request_context_.reset(new TestURLRequestContext(fs_)); | 743 url_request_context_.reset(new TestURLRequestContext(fs_)); |
| 745 url_request_context_->blob_storage_controller()->AddFinishedBlob( | 744 url_request_context_->blob_storage_controller()->AddFinishedBlob( |
| 746 blob_url(), blob_data_); | 745 blob_url(), blob_data_); |
| 747 operation()->Write( | 746 operation()->Write( |
| 748 url_request_context_.get(), | 747 url_request_context_.get(), |
| 749 fileapi::FileSystemURL(GURL(root_ + filename_)), | 748 fs_->CrackURL(GURL(root_ + filename_)), |
| 750 blob_url(), | 749 blob_url(), |
| 751 0, // offset | 750 0, // offset |
| 752 base::Bind(&HTML5FileWriter::WriteCallback, base::Unretained(this))); | 751 base::Bind(&HTML5FileWriter::WriteCallback, base::Unretained(this))); |
| 753 } | 752 } |
| 754 | 753 |
| 755 void WriteCallback( | 754 void WriteCallback( |
| 756 base::PlatformFileError result, | 755 base::PlatformFileError result, |
| 757 int64 bytes, | 756 int64 bytes, |
| 758 bool complete) { | 757 bool complete) { |
| 759 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 758 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| (...skipping 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2125 " \"state\": {" | 2124 " \"state\": {" |
| 2126 " \"previous\": \"in_progress\"," | 2125 " \"previous\": \"in_progress\"," |
| 2127 " \"current\": \"complete\"}}]", | 2126 " \"current\": \"complete\"}}]", |
| 2128 result_id, | 2127 result_id, |
| 2129 GetFilename("on_record.txt.crdownload").c_str(), | 2128 GetFilename("on_record.txt.crdownload").c_str(), |
| 2130 GetFilename("on_record.txt").c_str()))); | 2129 GetFilename("on_record.txt").c_str()))); |
| 2131 std::string disk_data; | 2130 std::string disk_data; |
| 2132 EXPECT_TRUE(file_util::ReadFileToString(item->GetFullPath(), &disk_data)); | 2131 EXPECT_TRUE(file_util::ReadFileToString(item->GetFullPath(), &disk_data)); |
| 2133 EXPECT_STREQ(kPayloadData, disk_data.c_str()); | 2132 EXPECT_STREQ(kPayloadData, disk_data.c_str()); |
| 2134 } | 2133 } |
| OLD | NEW |