| OLD | NEW |
| 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 "chrome/browser/sxs_linux.h" | 5 #include "chrome/browser/sxs_linux.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 12 #include "base/files/important_file_writer.h" | 12 #include "base/files/important_file_writer.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "base/stl_util.h" |
| 15 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
| 16 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 17 #include "chrome/common/channel_info.h" | 18 #include "chrome/common/channel_info.h" |
| 18 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
| 19 #include "chrome/common/chrome_result_codes.h" | 20 #include "chrome/common/chrome_result_codes.h" |
| 20 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 21 #include "components/version_info/version_info.h" | 22 #include "components/version_info/version_info.h" |
| 22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 66 |
| 66 // Note: failure to read the channels file is not fatal. It's possible | 67 // Note: failure to read the channels file is not fatal. It's possible |
| 67 // and legitimate that it doesn't exist, e.g. for new profile or for profile | 68 // and legitimate that it doesn't exist, e.g. for new profile or for profile |
| 68 // existing before channel marks have been introduced. | 69 // existing before channel marks have been introduced. |
| 69 std::string channels_contents; | 70 std::string channels_contents; |
| 70 if (base::ReadFileToString(channels_path, &channels_contents)) { | 71 if (base::ReadFileToString(channels_path, &channels_contents)) { |
| 71 base::SplitString(channels_contents, "\n", | 72 base::SplitString(channels_contents, "\n", |
| 72 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 73 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 73 } | 74 } |
| 74 | 75 |
| 75 if (std::find(user_data_dir_channels.begin(), | 76 if (ContainsValue(user_data_dir_channels, product_channel_name)) { |
| 76 user_data_dir_channels.end(), | |
| 77 product_channel_name) != user_data_dir_channels.end()) { | |
| 78 // No need to do further disk writes if our channel mark is already present. | 77 // No need to do further disk writes if our channel mark is already present. |
| 79 return true; | 78 return true; |
| 80 } | 79 } |
| 81 | 80 |
| 82 user_data_dir_channels.push_back(product_channel_name); | 81 user_data_dir_channels.push_back(product_channel_name); |
| 83 return base::ImportantFileWriter::WriteFileAtomically( | 82 return base::ImportantFileWriter::WriteFileAtomically( |
| 84 channels_path, | 83 channels_path, |
| 85 base::JoinString(user_data_dir_channels, "\n")); | 84 base::JoinString(user_data_dir_channels, "\n")); |
| 86 } | 85 } |
| 87 | 86 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 if (!base::Move(source_path, target_path)) { | 148 if (!base::Move(source_path, target_path)) { |
| 150 LOG(ERROR) << "Failed to rename '" << source_path.value() | 149 LOG(ERROR) << "Failed to rename '" << source_path.value() |
| 151 << "' to '" << target_path.value() << "'"; | 150 << "' to '" << target_path.value() << "'"; |
| 152 return chrome::RESULT_CODE_SXS_MIGRATION_FAILED; | 151 return chrome::RESULT_CODE_SXS_MIGRATION_FAILED; |
| 153 } | 152 } |
| 154 | 153 |
| 155 return content::RESULT_CODE_NORMAL_EXIT; | 154 return content::RESULT_CODE_NORMAL_EXIT; |
| 156 } | 155 } |
| 157 | 156 |
| 158 } // namespace sxs_linux | 157 } // namespace sxs_linux |
| OLD | NEW |