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/logging.h" | 10 #include "base/logging.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 return base::ImportantFileWriter::WriteFileAtomically( | 82 return base::ImportantFileWriter::WriteFileAtomically( |
83 channels_path, | 83 channels_path, |
84 JoinString(user_data_dir_channels, "\n")); | 84 JoinString(user_data_dir_channels, "\n")); |
85 } | 85 } |
86 | 86 |
87 } // namespace | 87 } // namespace |
88 | 88 |
89 namespace sxs_linux { | 89 namespace sxs_linux { |
90 | 90 |
91 void AddChannelMarkToUserDataDir() { | 91 void AddChannelMarkToUserDataDir() { |
92 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | 92 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
93 base::FilePath user_data_dir; | 93 base::FilePath user_data_dir; |
94 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { | 94 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { |
95 LOG(ERROR) << "Failed to get user data dir path. The profile will not be " | 95 LOG(ERROR) << "Failed to get user data dir path. The profile will not be " |
96 << "automatically migrated for updated Linux packages."; | 96 << "automatically migrated for updated Linux packages."; |
97 return; | 97 return; |
98 } | 98 } |
99 | 99 |
100 if (!DoAddChannelMarkToUserDataDir(user_data_dir)) { | 100 if (!DoAddChannelMarkToUserDataDir(user_data_dir)) { |
101 LOG(ERROR) << "Failed to add channel mark to the user data dir (" | 101 LOG(ERROR) << "Failed to add channel mark to the user data dir (" |
102 << user_data_dir.value() << "). This profile will not be " | 102 << user_data_dir.value() << "). This profile will not be " |
103 << "automatically migrated for updated Linux packages."; | 103 << "automatically migrated for updated Linux packages."; |
104 } | 104 } |
105 } | 105 } |
106 | 106 |
107 bool ShouldMigrateUserDataDir() { | 107 bool ShouldMigrateUserDataDir() { |
108 return CommandLine::ForCurrentProcess()->HasSwitch( | 108 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
109 switches::kMigrateDataDirForSxS); | 109 switches::kMigrateDataDirForSxS); |
110 } | 110 } |
111 | 111 |
112 int MigrateUserDataDir() { | 112 int MigrateUserDataDir() { |
113 DCHECK(ShouldMigrateUserDataDir()); | 113 DCHECK(ShouldMigrateUserDataDir()); |
114 | 114 |
115 base::FilePath source_path; | 115 base::FilePath source_path; |
116 if (!PathService::Get(chrome::DIR_USER_DATA, &source_path)) { | 116 if (!PathService::Get(chrome::DIR_USER_DATA, &source_path)) { |
117 LOG(ERROR) << "Failed to get value of chrome::DIR_USER_DATA"; | 117 LOG(ERROR) << "Failed to get value of chrome::DIR_USER_DATA"; |
118 return chrome::RESULT_CODE_SXS_MIGRATION_FAILED; | 118 return chrome::RESULT_CODE_SXS_MIGRATION_FAILED; |
(...skipping 16 matching lines...) Expand all Loading... |
135 return chrome::RESULT_CODE_SXS_MIGRATION_FAILED; | 135 return chrome::RESULT_CODE_SXS_MIGRATION_FAILED; |
136 } | 136 } |
137 | 137 |
138 if (user_data_dir_channels[0] != GetChannelMarkForThisExecutable()) { | 138 if (user_data_dir_channels[0] != GetChannelMarkForThisExecutable()) { |
139 LOG(WARNING) << "User data dir migration is only possible when the profile " | 139 LOG(WARNING) << "User data dir migration is only possible when the profile " |
140 << "is used with the same channel."; | 140 << "is used with the same channel."; |
141 return chrome::RESULT_CODE_SXS_MIGRATION_FAILED; | 141 return chrome::RESULT_CODE_SXS_MIGRATION_FAILED; |
142 } | 142 } |
143 | 143 |
144 base::FilePath target_path = | 144 base::FilePath target_path = |
145 CommandLine::ForCurrentProcess()->GetSwitchValuePath( | 145 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
146 switches::kMigrateDataDirForSxS); | 146 switches::kMigrateDataDirForSxS); |
147 | 147 |
148 if (!base::Move(source_path, target_path)) { | 148 if (!base::Move(source_path, target_path)) { |
149 LOG(ERROR) << "Failed to rename '" << source_path.value() | 149 LOG(ERROR) << "Failed to rename '" << source_path.value() |
150 << "' to '" << target_path.value() << "'"; | 150 << "' to '" << target_path.value() << "'"; |
151 return chrome::RESULT_CODE_SXS_MIGRATION_FAILED; | 151 return chrome::RESULT_CODE_SXS_MIGRATION_FAILED; |
152 } | 152 } |
153 | 153 |
154 return content::RESULT_CODE_NORMAL_EXIT; | 154 return content::RESULT_CODE_NORMAL_EXIT; |
155 } | 155 } |
156 | 156 |
157 } // namespace sxs_linux | 157 } // namespace sxs_linux |
OLD | NEW |