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

Side by Side Diff: services/resource_coordinator/coordination_unit/coordination_unit_graph_observer.h

Issue 2926663003: [GRC] Coordination Unit Graph Observer (Closed)
Patch Set: Rebase Created 3 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 2017 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 #ifndef SERVICES_RESOURCE_COORDINATOR_COORDINATION_UNIT_COORDINATION_UNIT_GRAPH_ OBSERVER_H_
6 #define SERVICES_RESOURCE_COORDINATOR_COORDINATION_UNIT_COORDINATION_UNIT_GRAPH_ OBSERVER_H_
7
8 #include <memory>
9 #include <unordered_map>
10
11 #include "base/macros.h"
12 #include "services/resource_coordinator/public/cpp/coordination_unit_id.h"
13 #include "services/resource_coordinator/public/cpp/coordination_unit_types.h"
14 #include "services/resource_coordinator/public/interfaces/coordination_unit.mojo m.h"
15
16 namespace resource_coordinator {
17
18 class CoordinationUnitImpl;
19
20 // An observer API for the CoordinationUnitGraph maintained by GRC.
21 //
22 // Observers are instantiated when the resource_coordinator serivce
23 // is created and are destroyed when the resource_coordinator service
24 // is destroyed. Therefore observers are guaranteed to be alive before
25 // any coordination unit is created and will be alive after any
26 // coordination unit is destroyed. Additionally, any
27 // Coordination Unit reachable within a callback will always be
28 // initialized and valid.
29 //
30 // To create and install a new observer:
31 // (1) derive from this class
32 // (2) register in CoordinationUnitManager::RegisterObserver
33 // inside of CoordinationUnitManager::CoordinationUnitManager
34 //
35 class CoordinationUnitGraphObserver {
36 public:
37 CoordinationUnitGraphObserver();
38 // The CoordinationUnitmanagerObserver will only call
Zhen Wang 2017/06/15 20:07:52 s/CoordinationUnitmanagerObserver/CoordinationUnit
matthalp 2017/06/16 00:01:26 Yes. Thank you for catching this.
39 // CoordinationUnitGraphObserver::CoordinationUnitCreated when the
40 // CoordinationUnit's CoordinationUnitID.type matches filter.
41 explicit CoordinationUnitGraphObserver(CoordinationUnitType filter);
42 virtual ~CoordinationUnitGraphObserver();
43
44 CoordinationUnitType filter() const { return filter_; }
Zhen Wang 2017/06/15 20:07:52 Instead of exposing filter type, how about using s
matthalp 2017/06/16 00:01:26 That is definitely cleaner -- done.
45
46 // Called whenever any new CoordinationUnit of any type is created. Note that
Zhen Wang 2017/06/15 20:07:52 This is only called when it matches the filter, ri
matthalp 2017/06/16 00:01:27 Done. Please let me know if the new comments are s
47 // this will be called after any specialized *CoordinationUnitCreated (e.g.
48 // FrameCoordinationUnitCreation, etc.) is called.
49 virtual void CoordinationUnitCreated(
50 CoordinationUnitImpl* coordination_unit) {}
51
52 private:
53 CoordinationUnitType filter_;
54
55 DISALLOW_COPY_AND_ASSIGN(CoordinationUnitGraphObserver);
56 };
57
58 } // namespace resource_coordinator
59
60 #endif // SERVICES_RESOURCE_COORDINATOR_COORDINATION_UNIT_COORDINATION_UNIT_GRA PH_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698