Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: components/offline_pages/core/offline_page_test_archiver.cc

Issue 2683493002: Get signals working in the EXTRA_DATA section of MHTML (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/offline_pages/core/offline_page_test_archiver.h" 5 #include "components/offline_pages/core/offline_page_test_archiver.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 17 matching lines...) Expand all
28 result_title_(result_title), 28 result_title_(result_title),
29 task_runner_(task_runner) {} 29 task_runner_(task_runner) {}
30 30
31 OfflinePageTestArchiver::~OfflinePageTestArchiver() { 31 OfflinePageTestArchiver::~OfflinePageTestArchiver() {
32 EXPECT_TRUE(create_archive_called_); 32 EXPECT_TRUE(create_archive_called_);
33 } 33 }
34 34
35 void OfflinePageTestArchiver::CreateArchive( 35 void OfflinePageTestArchiver::CreateArchive(
36 const base::FilePath& archives_dir, 36 const base::FilePath& archives_dir,
37 const CreateArchiveParams& create_archive_params, 37 const CreateArchiveParams& create_archive_params,
38 const std::vector<std::string>& signal_data,
38 const CreateArchiveCallback& callback) { 39 const CreateArchiveCallback& callback) {
39 create_archive_called_ = true; 40 create_archive_called_ = true;
40 callback_ = callback; 41 callback_ = callback;
41 archives_dir_ = archives_dir; 42 archives_dir_ = archives_dir;
42 create_archive_params_ = create_archive_params; 43 create_archive_params_ = create_archive_params;
43 if (!delayed_) 44 if (!delayed_)
44 CompleteCreateArchive(); 45 CompleteCreateArchive();
45 } 46 }
46 47
47 void OfflinePageTestArchiver::CompleteCreateArchive() { 48 void OfflinePageTestArchiver::CompleteCreateArchive() {
48 DCHECK(!callback_.is_null()); 49 DCHECK(!callback_.is_null());
49 base::FilePath archive_path; 50 base::FilePath archive_path;
50 if (filename_.empty()) { 51 if (filename_.empty()) {
51 ASSERT_TRUE(base::CreateTemporaryFileInDir(archives_dir_, &archive_path)); 52 ASSERT_TRUE(base::CreateTemporaryFileInDir(archives_dir_, &archive_path));
52 } else { 53 } else {
53 archive_path = archives_dir_.Append(filename_); 54 archive_path = archives_dir_.Append(filename_);
54 // This step ensures the file is created and closed immediately. 55 // This step ensures the file is created and closed immediately.
55 base::File file(archive_path, base::File::FLAG_OPEN_ALWAYS); 56 base::File file(archive_path, base::File::FLAG_OPEN_ALWAYS);
56 } 57 }
57 observer_->SetLastPathCreatedByArchiver(archive_path); 58 observer_->SetLastPathCreatedByArchiver(archive_path);
58 task_runner_->PostTask( 59 task_runner_->PostTask(
59 FROM_HERE, base::Bind(callback_, this, result_, url_, archive_path, 60 FROM_HERE, base::Bind(callback_, this, result_, url_, archive_path,
60 result_title_, size_to_report_)); 61 result_title_, size_to_report_));
61 } 62 }
62 63
63 } // namespace offline_pages 64 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698