| 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/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "net/base/data_url.h" | 42 #include "net/base/data_url.h" |
| 43 #include "net/base/net_util.h" | 43 #include "net/base/net_util.h" |
| 44 #include "net/url_request/url_request.h" | 44 #include "net/url_request/url_request.h" |
| 45 #include "net/url_request/url_request_context.h" | 45 #include "net/url_request/url_request_context.h" |
| 46 #include "net/url_request/url_request_job.h" | 46 #include "net/url_request/url_request_job.h" |
| 47 #include "net/url_request/url_request_job_factory.h" | 47 #include "net/url_request/url_request_job_factory.h" |
| 48 #include "webkit/blob/blob_data.h" | 48 #include "webkit/blob/blob_data.h" |
| 49 #include "webkit/blob/blob_storage_controller.h" | 49 #include "webkit/blob/blob_storage_controller.h" |
| 50 #include "webkit/blob/blob_url_request_job.h" | 50 #include "webkit/blob/blob_url_request_job.h" |
| 51 #include "webkit/fileapi/file_system_context.h" | 51 #include "webkit/fileapi/file_system_context.h" |
| 52 #include "webkit/fileapi/file_system_operation_interface.h" | 52 #include "webkit/fileapi/file_system_operation.h" |
| 53 #include "webkit/fileapi/file_system_url.h" | 53 #include "webkit/fileapi/file_system_url.h" |
| 54 | 54 |
| 55 using content::BrowserContext; | 55 using content::BrowserContext; |
| 56 using content::BrowserThread; | 56 using content::BrowserThread; |
| 57 using content::DownloadItem; | 57 using content::DownloadItem; |
| 58 using content::DownloadManager; | 58 using content::DownloadManager; |
| 59 using content::DownloadPersistentStoreInfo; | 59 using content::DownloadPersistentStoreInfo; |
| 60 | 60 |
| 61 namespace events = extensions::event_names; | 61 namespace events = extensions::event_names; |
| 62 | 62 |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 void OpenFileSystemCallback( | 713 void OpenFileSystemCallback( |
| 714 base::PlatformFileError result, | 714 base::PlatformFileError result, |
| 715 const std::string& fs_name, | 715 const std::string& fs_name, |
| 716 const GURL& root) { | 716 const GURL& root) { |
| 717 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 717 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 718 root_ = root.spec(); | 718 root_ = root.spec(); |
| 719 CHECK(BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( | 719 CHECK(BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( |
| 720 &HTML5FileWriter::CreateFile, base::Unretained(this)))); | 720 &HTML5FileWriter::CreateFile, base::Unretained(this)))); |
| 721 } | 721 } |
| 722 | 722 |
| 723 fileapi::FileSystemOperationInterface* operation() { | 723 fileapi::FileSystemOperation* operation() { |
| 724 return fs_->CreateFileSystemOperation(fileapi::FileSystemURL(GURL(root_))); | 724 return fs_->CreateFileSystemOperation(fileapi::FileSystemURL(GURL(root_))); |
| 725 } | 725 } |
| 726 | 726 |
| 727 void CreateFile() { | 727 void CreateFile() { |
| 728 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 728 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 729 operation()->CreateFile(fileapi::FileSystemURL(GURL(root_ + filename_)), | 729 operation()->CreateFile(fileapi::FileSystemURL(GURL(root_ + filename_)), |
| 730 kExclusive, base::Bind( | 730 kExclusive, base::Bind( |
| 731 &HTML5FileWriter::CreateFileCallback, base::Unretained(this))); | 731 &HTML5FileWriter::CreateFileCallback, base::Unretained(this))); |
| 732 } | 732 } |
| 733 | 733 |
| (...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2083 " \"state\": {" | 2083 " \"state\": {" |
| 2084 " \"previous\": \"in_progress\"," | 2084 " \"previous\": \"in_progress\"," |
| 2085 " \"current\": \"complete\"}}]", | 2085 " \"current\": \"complete\"}}]", |
| 2086 result_id, | 2086 result_id, |
| 2087 GetFilename("on_record.txt.crdownload").c_str(), | 2087 GetFilename("on_record.txt.crdownload").c_str(), |
| 2088 GetFilename("on_record.txt").c_str()))); | 2088 GetFilename("on_record.txt").c_str()))); |
| 2089 std::string disk_data; | 2089 std::string disk_data; |
| 2090 EXPECT_TRUE(file_util::ReadFileToString(item->GetFullPath(), &disk_data)); | 2090 EXPECT_TRUE(file_util::ReadFileToString(item->GetFullPath(), &disk_data)); |
| 2091 EXPECT_STREQ(kPayloadData, disk_data.c_str()); | 2091 EXPECT_STREQ(kPayloadData, disk_data.c_str()); |
| 2092 } | 2092 } |
| OLD | NEW |