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 if (!coordinator_) { | |
|
fgorski
2016/11/30 17:30:47
Since you only use this here, I don't think you ne
romax
2016/12/01 01:47:52
Acknowledged.
yeah but this schedule might be call
| |
| 57 coordinator_ = | |
| 58 RequestCoordinatorFactory::GetInstance()->GetForBrowserContext(profile); | |
|
fgorski
2016/11/30 17:30:47
what if your profile is null here, or incognito, a
romax
2016/12/01 01:47:52
I didn't think about this case since this schedule
fgorski
2016/12/01 21:42:52
Go ahead.
romax
2016/12/02 01:57:48
Done.
| |
| 59 } | |
| 60 coordinator_->GetLogger()->RecordActivity(OFFLINE_LOG_TAG + | |
| 61 "Start schedule!"); | |
| 54 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 62 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
| 55 base::Bind(&StartProcessing)); | 63 base::Bind(&StartProcessing)); |
| 56 } | 64 } |
| 57 | 65 |
| 58 void EvaluationTestScheduler::BackupSchedule( | 66 void EvaluationTestScheduler::BackupSchedule( |
| 59 const TriggerConditions& trigger_conditions, | 67 const TriggerConditions& trigger_conditions, |
| 60 long delay_in_seconds) {} | 68 long delay_in_seconds) {} |
| 61 | 69 |
| 62 void EvaluationTestScheduler::Unschedule() {} | 70 void EvaluationTestScheduler::Unschedule() {} |
| 63 | 71 |
| 64 void EvaluationTestScheduler::ImmediateScheduleCallback(bool result) { | 72 void EvaluationTestScheduler::ImmediateScheduleCallback(bool result) { |
| 65 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 73 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
| 66 base::Bind(&StartProcessing)); | 74 base::Bind(&StartProcessing)); |
| 67 } | 75 } |
| 68 | 76 |
| 69 } // namespace android | 77 } // namespace android |
| 70 } // namespace offline_pages | 78 } // namespace offline_pages |
| OLD | NEW |