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

Side by Side Diff: components/update_client/test_installer.cc

Issue 2918653003: Unconditionally delete the unpack path in the UpdateClient. (Closed)
Patch Set: Created 3 years, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "components/update_client/test_installer.h" 5 #include "components/update_client/test_installer.h"
6 6
7 #include <string> 7 #include <string>
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"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "components/update_client/update_client_errors.h" 12 #include "components/update_client/update_client_errors.h"
13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 namespace update_client { 15 namespace update_client {
15 16
16 TestInstaller::TestInstaller() : error_(0), install_count_(0) { 17 TestInstaller::TestInstaller() : error_(0), install_count_(0) {
17 } 18 }
18 19
20 TestInstaller::~TestInstaller() {
21 // The unpack path is deleted unconditionally by the component state code,
22 // which is driving this installer. Therefore, the unpack path must not
23 // exist when this object is destroyed.
24 if (!unpack_path_.empty())
25 EXPECT_FALSE(base::DirectoryExists(unpack_path_));
26 }
27
19 void TestInstaller::OnUpdateError(int error) { 28 void TestInstaller::OnUpdateError(int error) {
20 error_ = error; 29 error_ = error;
21 } 30 }
22 31
23 CrxInstaller::Result TestInstaller::Install( 32 CrxInstaller::Result TestInstaller::Install(
24 const base::DictionaryValue& manifest, 33 const base::DictionaryValue& manifest,
25 const base::FilePath& unpack_path) { 34 const base::FilePath& unpack_path) {
26 ++install_count_; 35 ++install_count_;
27 if (!base::DeleteFile(unpack_path, true)) 36
28 return Result(InstallError::GENERIC_ERROR); 37 unpack_path_ = unpack_path;
29 38
30 return Result(InstallError::NONE); 39 return Result(InstallError::NONE);
31 } 40 }
32 41
33 bool TestInstaller::GetInstalledFile(const std::string& file, 42 bool TestInstaller::GetInstalledFile(const std::string& file,
34 base::FilePath* installed_file) { 43 base::FilePath* installed_file) {
35 return false; 44 return false;
36 } 45 }
37 46
38 TestInstaller::~TestInstaller() {
39 }
40
41 bool TestInstaller::Uninstall() { 47 bool TestInstaller::Uninstall() {
42 return false; 48 return false;
43 } 49 }
44 50
45 ReadOnlyTestInstaller::ReadOnlyTestInstaller(const base::FilePath& install_dir) 51 ReadOnlyTestInstaller::ReadOnlyTestInstaller(const base::FilePath& install_dir)
46 : install_directory_(install_dir) { 52 : install_directory_(install_dir) {
47 } 53 }
48 54
49 ReadOnlyTestInstaller::~ReadOnlyTestInstaller() { 55 ReadOnlyTestInstaller::~ReadOnlyTestInstaller() {
50 } 56 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 88
83 bool VersionedTestInstaller::GetInstalledFile(const std::string& file, 89 bool VersionedTestInstaller::GetInstalledFile(const std::string& file,
84 base::FilePath* installed_file) { 90 base::FilePath* installed_file) {
85 base::FilePath path; 91 base::FilePath path;
86 path = install_directory_.AppendASCII(current_version_.GetString()); 92 path = install_directory_.AppendASCII(current_version_.GetString());
87 *installed_file = path.Append(base::FilePath::FromUTF8Unsafe(file)); 93 *installed_file = path.Append(base::FilePath::FromUTF8Unsafe(file));
88 return true; 94 return true;
89 } 95 }
90 96
91 } // namespace update_client 97 } // namespace update_client
OLDNEW
« no previous file with comments | « components/update_client/test_installer.h ('k') | components/update_client/update_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698