Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/android/offline_pages/evaluation/evaluation_test_schedu ler.h" | 5 #include "chrome/browser/android/offline_pages/evaluation/evaluation_test_schedu ler.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/threading/thread_task_runner_handle.h" | 8 #include "base/threading/thread_task_runner_handle.h" |
| 9 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h" | 9 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
| 12 #include "components/offline_pages/background/device_conditions.h" | 12 #include "components/offline_pages/background/device_conditions.h" |
| 13 #include "components/offline_pages/background/request_coordinator.h" | 13 #include "components/offline_pages/background/request_coordinator.h" |
| 14 #include "components/offline_pages/offline_event_logger.h" | |
| 14 #include "net/base/network_change_notifier.h" | 15 #include "net/base/network_change_notifier.h" |
| 15 | 16 |
| 16 namespace offline_pages { | 17 namespace offline_pages { |
| 17 | 18 |
| 18 namespace android { | 19 namespace android { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 void StartProcessing(); | 23 void StartProcessing(); |
| 23 | 24 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 44 Profile* profile = ProfileManager::GetLastUsedProfile(); | 45 Profile* profile = ProfileManager::GetLastUsedProfile(); |
| 45 RequestCoordinator* coordinator = | 46 RequestCoordinator* coordinator = |
| 46 RequestCoordinatorFactory::GetInstance()->GetForBrowserContext(profile); | 47 RequestCoordinatorFactory::GetInstance()->GetForBrowserContext(profile); |
| 47 coordinator->GetAllRequests(base::Bind(&GetAllRequestsDone)); | 48 coordinator->GetAllRequests(base::Bind(&GetAllRequestsDone)); |
| 48 } | 49 } |
| 49 | 50 |
| 50 } // namespace | 51 } // namespace |
| 51 | 52 |
| 52 void EvaluationTestScheduler::Schedule( | 53 void EvaluationTestScheduler::Schedule( |
| 53 const TriggerConditions& trigger_conditions) { | 54 const TriggerConditions& trigger_conditions) { |
| 55 Profile* profile = ProfileManager::GetLastUsedProfile(); | |
| 56 RequestCoordinator* coordinator = | |
| 57 RequestCoordinatorFactory::GetInstance()->GetForBrowserContext(profile); | |
|
dougarnett
2016/11/28 23:02:44
how about getting the coordinator once and holding
romax
2016/11/30 00:15:10
Done.
| |
| 58 coordinator->GetLogger()->RecordActivity(OFFLINE_LOG_TAG + "Start schedule!"); | |
| 54 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 59 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
| 55 base::Bind(&StartProcessing)); | 60 base::Bind(&StartProcessing)); |
| 56 } | 61 } |
| 57 | 62 |
| 58 void EvaluationTestScheduler::BackupSchedule( | 63 void EvaluationTestScheduler::BackupSchedule( |
| 59 const TriggerConditions& trigger_conditions, | 64 const TriggerConditions& trigger_conditions, |
| 60 long delay_in_seconds) {} | 65 long delay_in_seconds) {} |
| 61 | 66 |
| 62 void EvaluationTestScheduler::Unschedule() {} | 67 void EvaluationTestScheduler::Unschedule() {} |
| 63 | 68 |
| 64 void EvaluationTestScheduler::ImmediateScheduleCallback(bool result) { | 69 void EvaluationTestScheduler::ImmediateScheduleCallback(bool result) { |
| 65 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 70 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
| 66 base::Bind(&StartProcessing)); | 71 base::Bind(&StartProcessing)); |
| 67 } | 72 } |
| 68 | 73 |
| 69 } // namespace android | 74 } // namespace android |
| 70 } // namespace offline_pages | 75 } // namespace offline_pages |
| OLD | NEW |