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

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

Issue 1928393003: Using separate directories based on LifetimeType. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « components/offline_pages/offline_page_model_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/offline_page_test_archiver.h" 5 #include "components/offline_pages/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 27 matching lines...) Expand all
38 callback_ = callback; 38 callback_ = callback;
39 archives_dir_ = archives_dir; 39 archives_dir_ = archives_dir;
40 if (!delayed_) 40 if (!delayed_)
41 CompleteCreateArchive(); 41 CompleteCreateArchive();
42 } 42 }
43 43
44 void OfflinePageTestArchiver::CompleteCreateArchive() { 44 void OfflinePageTestArchiver::CompleteCreateArchive() {
45 DCHECK(!callback_.is_null()); 45 DCHECK(!callback_.is_null());
46 base::FilePath archive_path; 46 base::FilePath archive_path;
47 if (filename_.empty()) { 47 if (filename_.empty()) {
48 ASSERT_TRUE(base::CreateDirectory(archives_dir_));
48 ASSERT_TRUE(base::CreateTemporaryFileInDir(archives_dir_, &archive_path)); 49 ASSERT_TRUE(base::CreateTemporaryFileInDir(archives_dir_, &archive_path));
49 } else { 50 } else {
50 archive_path = archives_dir_.Append(filename_); 51 archive_path = archives_dir_.Append(filename_);
51 // This step ensures the file is created and closed immediately. 52 // This step ensures the file is created and closed immediately.
52 base::File file(archive_path, base::File::FLAG_OPEN_ALWAYS); 53 base::File file(archive_path, base::File::FLAG_OPEN_ALWAYS);
53 } 54 }
54 observer_->SetLastPathCreatedByArchiver(archive_path); 55 observer_->SetLastPathCreatedByArchiver(archive_path);
55 task_runner_->PostTask(FROM_HERE, base::Bind(callback_, this, result_, url_, 56 task_runner_->PostTask(FROM_HERE, base::Bind(callback_, this, result_, url_,
56 archive_path, size_to_report_)); 57 archive_path, size_to_report_));
57 } 58 }
58 59
59 } // namespace offline_pages 60 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/offline_page_model_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698