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

Side by Side Diff: chrome/installer/setup/setup_util.cc

Issue 1878313003: Convert //chrome/installer from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert decompress.cc in mini_installer. Created 4 years, 8 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 | « chrome/installer/setup/setup_main.cc ('k') | chrome/installer/setup/setup_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // This file declares util functions for setup project. 5 // This file declares util functions for setup project.
6 6
7 #include "chrome/installer/setup/setup_util.h" 7 #include "chrome/installer/setup/setup_util.h"
8 8
9 #include <windows.h> 9 #include <windows.h>
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 return exit_code; 96 return exit_code;
97 } 97 }
98 98
99 Version* GetMaxVersionFromArchiveDir(const base::FilePath& chrome_path) { 99 Version* GetMaxVersionFromArchiveDir(const base::FilePath& chrome_path) {
100 VLOG(1) << "Looking for Chrome version folder under " << chrome_path.value(); 100 VLOG(1) << "Looking for Chrome version folder under " << chrome_path.value();
101 base::FileEnumerator version_enum(chrome_path, false, 101 base::FileEnumerator version_enum(chrome_path, false,
102 base::FileEnumerator::DIRECTORIES); 102 base::FileEnumerator::DIRECTORIES);
103 // TODO(tommi): The version directory really should match the version of 103 // TODO(tommi): The version directory really should match the version of
104 // setup.exe. To begin with, we should at least DCHECK that that's true. 104 // setup.exe. To begin with, we should at least DCHECK that that's true.
105 105
106 scoped_ptr<Version> max_version(new Version("0.0.0.0")); 106 std::unique_ptr<Version> max_version(new Version("0.0.0.0"));
107 bool version_found = false; 107 bool version_found = false;
108 108
109 while (!version_enum.Next().empty()) { 109 while (!version_enum.Next().empty()) {
110 base::FileEnumerator::FileInfo find_data = version_enum.GetInfo(); 110 base::FileEnumerator::FileInfo find_data = version_enum.GetInfo();
111 VLOG(1) << "directory found: " << find_data.GetName().value(); 111 VLOG(1) << "directory found: " << find_data.GetName().value();
112 112
113 scoped_ptr<Version> found_version( 113 std::unique_ptr<Version> found_version(
114 new Version(base::UTF16ToASCII(find_data.GetName().value()))); 114 new Version(base::UTF16ToASCII(find_data.GetName().value())));
115 if (found_version->IsValid() && 115 if (found_version->IsValid() &&
116 found_version->CompareTo(*max_version.get()) > 0) { 116 found_version->CompareTo(*max_version.get()) > 0) {
117 max_version.reset(found_version.release()); 117 max_version.reset(found_version.release());
118 version_found = true; 118 version_found = true;
119 } 119 }
120 } 120 }
121 121
122 return (version_found ? max_version.release() : NULL); 122 return (version_found ? max_version.release() : NULL);
123 } 123 }
(...skipping 13 matching lines...) Expand all
137 base::FilePath patch_source; 137 base::FilePath patch_source;
138 const ProductState* product = 138 const ProductState* product =
139 original_state.GetProductState(installer_state.system_install(), 139 original_state.GetProductState(installer_state.system_install(),
140 installer_state.state_type()); 140 installer_state.state_type());
141 if (product) { 141 if (product) {
142 patch_source = installer_state.GetInstallerDirectory(product->version()) 142 patch_source = installer_state.GetInstallerDirectory(product->version())
143 .Append(installer::kChromeArchive); 143 .Append(installer::kChromeArchive);
144 if (base::PathExists(patch_source)) 144 if (base::PathExists(patch_source))
145 return patch_source; 145 return patch_source;
146 } 146 }
147 scoped_ptr<Version> version( 147 std::unique_ptr<Version> version(
148 installer::GetMaxVersionFromArchiveDir(installer_state.target_path())); 148 installer::GetMaxVersionFromArchiveDir(installer_state.target_path()));
149 if (version) { 149 if (version) {
150 patch_source = installer_state.GetInstallerDirectory(*version) 150 patch_source = installer_state.GetInstallerDirectory(*version)
151 .Append(installer::kChromeArchive); 151 .Append(installer::kChromeArchive);
152 if (base::PathExists(patch_source)) 152 if (base::PathExists(patch_source))
153 return patch_source; 153 return patch_source;
154 } 154 }
155 return base::FilePath(); 155 return base::FilePath();
156 } 156 }
157 157
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 } 575 }
576 576
577 ScopedTokenPrivilege::~ScopedTokenPrivilege() { 577 ScopedTokenPrivilege::~ScopedTokenPrivilege() {
578 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { 578 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) {
579 ::AdjustTokenPrivileges(token_.Get(), FALSE, &previous_privileges_, 579 ::AdjustTokenPrivileges(token_.Get(), FALSE, &previous_privileges_,
580 sizeof(TOKEN_PRIVILEGES), NULL, NULL); 580 sizeof(TOKEN_PRIVILEGES), NULL, NULL);
581 } 581 }
582 } 582 }
583 583
584 } // namespace installer 584 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/installer/setup/setup_main.cc ('k') | chrome/installer/setup/setup_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698