| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/task_runner_util.h" | 10 #include "base/task_scheduler/post_task.h" |
| 11 #include "base/threading/worker_pool.h" | |
| 12 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
| 14 #include "chromeos/system/statistics_provider.h" | 13 #include "chromeos/system/statistics_provider.h" |
| 15 #include "components/prefs/pref_service.h" | 14 #include "components/prefs/pref_service.h" |
| 16 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 17 | 16 |
| 18 namespace google_brand { | 17 namespace google_brand { |
| 19 namespace chromeos { | 18 namespace chromeos { |
| 20 | 19 |
| 21 namespace { | 20 namespace { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 ::chromeos::system::StatisticsProvider* provider = | 67 ::chromeos::system::StatisticsProvider* provider = |
| 69 ::chromeos::system::StatisticsProvider::GetInstance(); | 68 ::chromeos::system::StatisticsProvider::GetInstance(); |
| 70 std::string brand; | 69 std::string brand; |
| 71 const bool found = provider->GetMachineStatistic( | 70 const bool found = provider->GetMachineStatistic( |
| 72 ::chromeos::system::kRlzBrandCodeKey, &brand); | 71 ::chromeos::system::kRlzBrandCodeKey, &brand); |
| 73 if (found && !brand.empty()) { | 72 if (found && !brand.empty()) { |
| 74 SetBrand(callback, brand); | 73 SetBrand(callback, brand); |
| 75 return; | 74 return; |
| 76 } | 75 } |
| 77 | 76 |
| 78 base::PostTaskAndReplyWithResult( | 77 base::PostTaskWithTraitsAndReplyWithResult( |
| 79 base::WorkerPool::GetTaskRunner(false /* task_is_slow */).get(), | 78 FROM_HERE, base::TaskTraits() |
| 80 FROM_HERE, | 79 .WithShutdownBehavior( |
| 81 base::Bind(&ReadBrandFromFile), | 80 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) |
| 82 base::Bind(&SetBrand, callback)); | 81 .WithPriority(base::TaskPriority::BACKGROUND) |
| 82 .WithFileIO(), |
| 83 base::Bind(&ReadBrandFromFile), base::Bind(&SetBrand, callback)); |
| 83 } | 84 } |
| 84 | 85 |
| 85 } // namespace chromeos | 86 } // namespace chromeos |
| 86 } // namespace google_brand | 87 } // namespace google_brand |
| OLD | NEW |