Index: mojo/services/test_service/toy_monitoring_service_impl.h |
diff --git a/mojo/services/test_service/toy_monitoring_service_impl.h b/mojo/services/test_service/toy_monitoring_service_impl.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1a78531f32f519f380d1650cb6d2134f308e901a |
--- /dev/null |
+++ b/mojo/services/test_service/toy_monitoring_service_impl.h |
@@ -0,0 +1,71 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef MOJO_SERVICES_TEST_SERVICE_TOY_MONITORING_SERVICE_IMPL_H_ |
+#define MOJO_SERVICES_TEST_SERVICE_TOY_MONITORING_SERVICE_IMPL_H_ |
+ |
+#include "base/memory/weak_ptr.h" |
+#include "mojo/public/cpp/system/macros.h" |
+#include "mojo/services/test_service/toy_monitoring_service.mojom.h" |
+ |
+namespace mojo { |
+class ApplicationConnection; |
+namespace test { |
+ |
+typedef std::map<uint64_t, std::vector<ServiceStats> > AllRecordsMap; |
+ |
+// Shared state between all instances of MonitoringServiceRecorder |
+// and the master MonitoringService. |
+struct MonitoringContext { |
+ MonitoringContext(); |
+ ~MonitoringContext(); |
+ AllRecordsMap records; |
+ std::map<uint64_t, std::string> ids_to_names; |
+ uint64_t next_id; |
+}; |
+ |
+class ToyMonitoringServiceRecorderImpl |
+ : public InterfaceImpl<ToyMonitoringServiceStatsRecorder> { |
+ public: |
+ ToyMonitoringServiceRecorderImpl( |
+ ApplicationConnection* connection, |
+ MonitoringContext* context); |
+ virtual ~ToyMonitoringServiceRecorderImpl(); |
+ |
+ // ToyMonitoringServiceStatsRecorder. |
+ virtual void RecordStats( |
+ uint64_t client_id, |
+ ServiceStatsPtr stats) MOJO_OVERRIDE; |
+ |
+ // InterfaceImpl override. |
+ virtual void OnConnectionEstablished() MOJO_OVERRIDE; |
+ |
+ private: |
+ void UploaderNameCallback(uint64_t id, const mojo::String& name); |
+ MonitoringContext* context_; |
+ base::WeakPtrFactory<ToyMonitoringServiceRecorderImpl> weak_factory_; |
+ MOJO_DISALLOW_COPY_AND_ASSIGN(ToyMonitoringServiceRecorderImpl); |
+}; |
+ |
+class ToyMonitoringServiceImpl : public InterfaceImpl<ToyMonitoringService> { |
+ public: |
+ ToyMonitoringServiceImpl( |
+ ApplicationConnection* connection, |
+ MonitoringContext* context); |
+ virtual ~ToyMonitoringServiceImpl(); |
+ |
+ // |ToyMonitoringService| implementation. |
+ virtual void GetReport( |
+ const mojo::Callback<void(mojo::Array<ServiceReportPtr>)>& callback) |
+ MOJO_OVERRIDE; |
+ |
+ private: |
+ MonitoringContext* context_; |
+ MOJO_DISALLOW_COPY_AND_ASSIGN(ToyMonitoringServiceImpl); |
+}; |
+ |
+} // namespace test |
+} // namespace mojo |
+ |
+#endif // MOJO_SERVICES_TEST_SERVICE_TOY_MONITORING_SERVICE_IMPL_H_ |