Fix layout of the Connection Tab of the Origin Info Bubble.
[chromium-blink-merge.git] / mojo / services / test_service / test_request_tracker_impl.h
blob0ed220ac0cb0effba1fbc4b1c9917a44c05f257f
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.
5 #ifndef SERVICES_TEST_SERVICE_TEST_REQUEST_TRACKER_IMPL_H_
6 #define SERVICES_TEST_SERVICE_TEST_REQUEST_TRACKER_IMPL_H_
8 #include "base/memory/weak_ptr.h"
9 #include "mojo/public/cpp/bindings/strong_binding.h"
10 #include "mojo/public/cpp/system/macros.h"
11 #include "mojo/services/test_service/test_request_tracker.mojom.h"
13 namespace mojo {
14 class ApplicationConnection;
15 namespace test {
17 typedef std::map<uint64_t, std::vector<ServiceStats> > AllRecordsMap;
19 // Shared state between all instances of TestRequestTrackerImpl
20 // and the master TrackedRequestService.
21 struct TrackingContext {
22 TrackingContext();
23 ~TrackingContext();
24 AllRecordsMap records;
25 std::map<uint64_t, std::string> ids_to_names;
26 uint64_t next_id;
29 class TestRequestTrackerImpl : public TestRequestTracker {
30 public:
31 TestRequestTrackerImpl(InterfaceRequest<TestRequestTracker> request,
32 TrackingContext* context);
33 ~TestRequestTrackerImpl() override;
35 // TestRequestTracker.
36 void SetNameAndReturnId(const String& service_name,
37 const Callback<void(uint64_t id)>& callback) override;
38 void RecordStats(uint64_t client_id, ServiceStatsPtr stats) override;
40 private:
41 void UploaderNameCallback(uint64_t id, const mojo::String& name);
42 TrackingContext* context_;
43 StrongBinding<TestRequestTracker> binding_;
44 base::WeakPtrFactory<TestRequestTrackerImpl> weak_factory_;
45 MOJO_DISALLOW_COPY_AND_ASSIGN(TestRequestTrackerImpl);
48 class TestTrackedRequestServiceImpl : public TestTrackedRequestService {
49 public:
50 TestTrackedRequestServiceImpl(
51 InterfaceRequest<TestTrackedRequestService> request,
52 TrackingContext* context);
53 ~TestTrackedRequestServiceImpl() override;
55 // |TestTrackedRequestService| implementation.
56 void GetReport(const mojo::Callback<void(mojo::Array<ServiceReportPtr>)>&
57 callback) override;
59 private:
60 TrackingContext* context_;
61 StrongBinding<TestTrackedRequestService> binding_;
63 MOJO_DISALLOW_COPY_AND_ASSIGN(TestTrackedRequestServiceImpl);
66 } // namespace test
67 } // namespace mojo
69 #endif // SERVICES_TEST_SERVICE_TEST_REQUEST_TRACKER_IMPL_H_