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

Side by Side Diff: mojo/services/test_service/toy_monitoring_service_impl.h

Issue 349303006: mojo: add some end-to-end shell tests and a new test sample app (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ServiceProvider rebase 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 | Annotate | Revision Log
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 #ifndef MOJO_SERVICES_TEST_SERVICE_TOY_MONITORING_SERVICE_IMPL_H_
6 #define MOJO_SERVICES_TEST_SERVICE_TOY_MONITORING_SERVICE_IMPL_H_
7
8 #include "base/memory/weak_ptr.h"
9 #include "mojo/public/cpp/system/macros.h"
10 #include "mojo/services/test_service/toy_monitoring_service.mojom.h"
11
12 namespace mojo {
13 class ApplicationConnection;
14 namespace test {
15
16 typedef std::map<uint64_t, std::vector<ServiceStats> > AllRecordsMap;
17
18 // Shared state between all instances of MonitoringServiceRecorder
19 // and the master MonitoringService.
20 struct MonitoringContext {
21 MonitoringContext();
22 ~MonitoringContext();
23 AllRecordsMap records;
24 std::map<uint64_t, std::string> ids_to_names;
25 uint64_t next_id;
26 };
27
28 class ToyMonitoringServiceRecorderImpl
29 : public InterfaceImpl<ToyMonitoringServiceStatsRecorder> {
30 public:
31 ToyMonitoringServiceRecorderImpl(
32 ApplicationConnection* connection,
33 MonitoringContext* context);
34 virtual ~ToyMonitoringServiceRecorderImpl();
35
36 // ToyMonitoringServiceStatsRecorder.
37 virtual void RecordStats(
38 uint64_t client_id,
39 ServiceStatsPtr stats) MOJO_OVERRIDE;
40
41 // InterfaceImpl override.
42 virtual void OnConnectionEstablished() MOJO_OVERRIDE;
43
44 private:
45 void UploaderNameCallback(uint64_t id, const mojo::String& name);
46 MonitoringContext* context_;
47 base::WeakPtrFactory<ToyMonitoringServiceRecorderImpl> weak_factory_;
48 MOJO_DISALLOW_COPY_AND_ASSIGN(ToyMonitoringServiceRecorderImpl);
49 };
50
51 class ToyMonitoringServiceImpl : public InterfaceImpl<ToyMonitoringService> {
52 public:
53 ToyMonitoringServiceImpl(
54 ApplicationConnection* connection,
55 MonitoringContext* context);
56 virtual ~ToyMonitoringServiceImpl();
57
58 // |ToyMonitoringService| implementation.
59 virtual void GetReport(
60 const mojo::Callback<void(mojo::Array<ServiceReportPtr>)>& callback)
61 MOJO_OVERRIDE;
62
63 private:
64 MonitoringContext* context_;
65 MOJO_DISALLOW_COPY_AND_ASSIGN(ToyMonitoringServiceImpl);
66 };
67
68 } // namespace test
69 } // namespace mojo
70
71 #endif // MOJO_SERVICES_TEST_SERVICE_TOY_MONITORING_SERVICE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698