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 "chrome/browser/sync/test/integration/sync_extension_installer.h" | 5 #include "chrome/browser/sync/test/integration/sync_extension_installer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/sync/test/integration/sync_extension_helper.h" | 12 #include "chrome/browser/sync/test/integration/sync_extension_helper.h" |
11 #include "content/public/browser/notification_source.h" | 13 #include "content/public/browser/notification_source.h" |
12 | 14 |
13 SyncedExtensionInstaller::SyncedExtensionInstaller(Profile* profile) | 15 SyncedExtensionInstaller::SyncedExtensionInstaller(Profile* profile) |
14 : profile_(profile), | 16 : profile_(profile), |
15 weak_ptr_factory_(this) { | 17 weak_ptr_factory_(this) { |
16 DoInstallSyncedExtensions(); | 18 DoInstallSyncedExtensions(); |
17 registrar_.Add(this, | 19 registrar_.Add(this, |
18 extensions::NOTIFICATION_EXTENSION_UPDATING_STARTED, | 20 extensions::NOTIFICATION_EXTENSION_UPDATING_STARTED, |
19 content::Source<Profile>(profile_)); | 21 content::Source<Profile>(profile_)); |
20 } | 22 } |
21 | 23 |
22 SyncedExtensionInstaller::~SyncedExtensionInstaller() { | 24 SyncedExtensionInstaller::~SyncedExtensionInstaller() { |
23 } | 25 } |
24 | 26 |
25 void SyncedExtensionInstaller::Observe( | 27 void SyncedExtensionInstaller::Observe( |
26 int type, | 28 int type, |
27 const content::NotificationSource& source, | 29 const content::NotificationSource& source, |
28 const content::NotificationDetails& details) { | 30 const content::NotificationDetails& details) { |
29 DCHECK_EQ(extensions::NOTIFICATION_EXTENSION_UPDATING_STARTED, type); | 31 DCHECK_EQ(extensions::NOTIFICATION_EXTENSION_UPDATING_STARTED, type); |
30 | 32 |
31 // The extension system is trying to check for updates. In the real world, | 33 // The extension system is trying to check for updates. In the real world, |
32 // this would be where synced extensions are asynchronously downloaded from | 34 // this would be where synced extensions are asynchronously downloaded from |
33 // the web store and installed. In this test framework, we use this event as | 35 // the web store and installed. In this test framework, we use this event as |
34 // a signal that it's time to asynchronously fake the installation of these | 36 // a signal that it's time to asynchronously fake the installation of these |
35 // extensions. | 37 // extensions. |
36 | 38 |
37 base::MessageLoop::current()->PostTask( | 39 base::ThreadTaskRunnerHandle::Get()->PostTask( |
38 FROM_HERE, | 40 FROM_HERE, |
39 base::Bind(&SyncedExtensionInstaller::DoInstallSyncedExtensions, | 41 base::Bind(&SyncedExtensionInstaller::DoInstallSyncedExtensions, |
40 weak_ptr_factory_.GetWeakPtr())); | 42 weak_ptr_factory_.GetWeakPtr())); |
41 } | 43 } |
42 | 44 |
43 void SyncedExtensionInstaller::DoInstallSyncedExtensions() { | 45 void SyncedExtensionInstaller::DoInstallSyncedExtensions() { |
44 SyncExtensionHelper::GetInstance()->InstallExtensionsPendingForSync(profile_); | 46 SyncExtensionHelper::GetInstance()->InstallExtensionsPendingForSync(profile_); |
45 } | 47 } |
OLD | NEW |