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

Side by Side Diff: components/arc/metrics/arc_metrics_service.h

Issue 2133503002: arc: Revamp the ArcBridgeService interface (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: More rebasing Created 4 years, 5 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
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 #ifndef COMPONENTS_ARC_METRICS_ARC_METRICS_SERVICE_H 5 #ifndef COMPONENTS_ARC_METRICS_ARC_METRICS_SERVICE_H_
6 #define COMPONENTS_ARC_METRICS_ARC_METRICS_SERVICE_H 6 #define COMPONENTS_ARC_METRICS_ARC_METRICS_SERVICE_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/threading/thread_checker.h" 10 #include "base/threading/thread_checker.h"
11 #include "base/timer/timer.h" 11 #include "base/timer/timer.h"
12 #include "components/arc/arc_bridge_service.h" 12 #include "components/arc/arc_bridge_service.h"
13 #include "components/arc/arc_service.h" 13 #include "components/arc/arc_service.h"
14 #include "components/arc/common/arc_bridge.mojom.h" 14 #include "components/arc/common/arc_bridge.mojom.h"
15 #include "components/arc/instance_holder.h"
15 #include "components/arc/metrics/oom_kills_monitor.h" 16 #include "components/arc/metrics/oom_kills_monitor.h"
16 #include "mojo/public/cpp/bindings/binding.h" 17 #include "mojo/public/cpp/bindings/binding.h"
17 18
18 namespace arc { 19 namespace arc {
19 20
20 // Collects information from other ArcServices and send UMA metrics. 21 // Collects information from other ArcServices and send UMA metrics.
21 class ArcMetricsService : public ArcService, 22 class ArcMetricsService
22 public ArcBridgeService::Observer, 23 : public ArcService,
23 public mojom::MetricsHost { 24 public InstanceHolder<mojom::MetricsInstance>::Observer,
25 public mojom::MetricsHost {
24 public: 26 public:
25 explicit ArcMetricsService(ArcBridgeService* bridge_service); 27 explicit ArcMetricsService(ArcBridgeService* bridge_service);
26 ~ArcMetricsService() override; 28 ~ArcMetricsService() override;
27 29
28 // ArcBridgeService::Observer overrides. 30 // InstanceHolder<mojom::MetricsInstance>::Observer overrides.
29 void OnMetricsInstanceReady() override; 31 void OnInstanceReady() override;
30 void OnMetricsInstanceClosed() override; 32 void OnInstanceClosed() override;
31 void OnProcessInstanceReady() override; 33
32 void OnProcessInstanceClosed() override; 34 // Implementations for InstanceHolder<mojom::ProcessInstance>::Observer.
35 void OnProcessInstanceReady();
36 void OnProcessInstanceClosed();
33 37
34 // MetricsHost overrides. 38 // MetricsHost overrides.
35 void ReportBootProgress( 39 void ReportBootProgress(
36 mojo::Array<arc::mojom::BootProgressEventPtr> events) override; 40 mojo::Array<arc::mojom::BootProgressEventPtr> events) override;
37 41
38 private: 42 private:
39 bool CalledOnValidThread(); 43 bool CalledOnValidThread();
40 void RequestProcessList(); 44 void RequestProcessList();
41 void ParseProcessList( 45 void ParseProcessList(
42 mojo::Array<arc::mojom::RunningAppProcessInfoPtr> processes); 46 mojo::Array<arc::mojom::RunningAppProcessInfoPtr> processes);
43 47
44 // DBus callbacks. 48 // DBus callbacks.
45 void OnArcStartTimeRetrieved(bool success, base::TimeTicks arc_start_time); 49 void OnArcStartTimeRetrieved(bool success, base::TimeTicks arc_start_time);
46 50
47 private: 51 private:
52 // Adapter to be able to also observe ProcessInstance events.
53 class ProcessObserver
54 : public InstanceHolder<mojom::ProcessInstance>::Observer {
55 public:
56 explicit ProcessObserver(ArcMetricsService* arc_metrics_service);
57 ~ProcessObserver() override;
58
59 private:
60 // InstanceHolder<mojom::ProcessInstance>::Observer overrides.
61 void OnInstanceReady() override;
62 void OnInstanceClosed() override;
63
64 ArcMetricsService* arc_metrics_service_;
65 };
66
48 mojo::Binding<mojom::MetricsHost> binding_; 67 mojo::Binding<mojom::MetricsHost> binding_;
49 68
69 ProcessObserver process_observer_;
50 base::ThreadChecker thread_checker_; 70 base::ThreadChecker thread_checker_;
51 base::RepeatingTimer timer_; 71 base::RepeatingTimer timer_;
52 72
53 OomKillsMonitor oom_kills_monitor_; 73 OomKillsMonitor oom_kills_monitor_;
54 74
55 base::TimeTicks arc_start_time_; 75 base::TimeTicks arc_start_time_;
56 76
57 // Always keep this the last member of this class to make sure it's the 77 // Always keep this the last member of this class to make sure it's the
58 // first thing to be destructed. 78 // first thing to be destructed.
59 base::WeakPtrFactory<ArcMetricsService> weak_ptr_factory_; 79 base::WeakPtrFactory<ArcMetricsService> weak_ptr_factory_;
60 80
61 DISALLOW_COPY_AND_ASSIGN(ArcMetricsService); 81 DISALLOW_COPY_AND_ASSIGN(ArcMetricsService);
62 }; 82 };
63 83
64 } // namespace arc 84 } // namespace arc
65 85
66 #endif // COMPONENTS_ARC_METRICS_ARC_METRICS_SERVICE_H 86 #endif // COMPONENTS_ARC_METRICS_ARC_METRICS_SERVICE_H_
OLDNEW
« no previous file with comments | « components/arc/intent_helper/link_handler_model_impl.cc ('k') | components/arc/metrics/arc_metrics_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698