Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(428)

Side by Side Diff: extensions/browser/extension_test_registry_observer.cc

Issue 334083002: Add a test helper class for ExtensionRegistry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "extensions/browser/extension_test_registry_observer.h"
6
7 #include "base/run_loop.h"
8
9 namespace extensions {
10
11 ExtensionTestRegistryObserver::ExtensionTestRegistryObserver(
12 ExtensionRegistry* registry)
13 : waiting_for_installed_(false),
14 received_installed_(false),
15 runner_installed_(new content::MessageLoopRunner()),
16 waiting_for_uninstalled_(false),
17 received_uninstalled_(false),
18 runner_uninstalled_(new content::MessageLoopRunner()),
19 extension_registry_observer_(this) {
20 extension_registry_observer_.Add(registry);
21 }
22
23 ExtensionTestRegistryObserver::~ExtensionTestRegistryObserver() {
24 }
25
26 void ExtensionTestRegistryObserver::WaitForExtensionUninstalled() {
27 if (received_uninstalled_)
28 return;
29
30 waiting_for_uninstalled_ = true;
31 runner_uninstalled_->Run();
not at google - send to devlin 2014/06/15 21:20:16 it would be nice to factor all of this shared stat
limasdf 2014/06/16 18:58:53 Done.
32 }
33
34 void ExtensionTestRegistryObserver::WaitForExtensionInstalled() {
35 if (received_installed_)
36 return;
37
38 waiting_for_installed_ = true;
39 runner_installed_->Run();
40 }
41
42 void ExtensionTestRegistryObserver::OnExtensionWillBeInstalled(
43 content::BrowserContext* browser_context,
44 const Extension* extension,
45 bool is_update,
46 bool from_ephemeral,
47 const std::string& old_name) {
48 received_installed_ = true;
49 if (waiting_for_installed_) {
50 waiting_for_installed_ = false;
51 runner_installed_->Quit();
52 }
53 }
54
55 void ExtensionTestRegistryObserver::OnExtensionUninstalled(
56 content::BrowserContext* browser_context,
57 const Extension* extension) {
58 received_uninstalled_ = true;
59 if (waiting_for_uninstalled_) {
60 waiting_for_uninstalled_ = false;
61 runner_uninstalled_->Quit();
62 }
63 }
64
65 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698