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

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

Issue 1049993002: Get mojo_shell building inside chromium checkout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix presubmit Created 5 years, 8 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 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 SERVICES_TEST_SERVICE_TEST_REQUEST_TRACKER_IMPL_H_
6 #define SERVICES_TEST_SERVICE_TEST_REQUEST_TRACKER_IMPL_H_
7
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"
12
13 namespace mojo {
14 class ApplicationConnection;
15 namespace test {
16
17 typedef std::map<uint64_t, std::vector<ServiceStats> > AllRecordsMap;
18
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;
27 };
28
29 class TestRequestTrackerImpl : public TestRequestTracker {
30 public:
31 TestRequestTrackerImpl(InterfaceRequest<TestRequestTracker> request,
32 TrackingContext* context);
33 ~TestRequestTrackerImpl() override;
34
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;
39
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);
46 };
47
48 class TestTrackedRequestServiceImpl : public TestTrackedRequestService {
49 public:
50 TestTrackedRequestServiceImpl(
51 InterfaceRequest<TestTrackedRequestService> request,
52 TrackingContext* context);
53 ~TestTrackedRequestServiceImpl() override;
54
55 // |TestTrackedRequestService| implementation.
56 void GetReport(const mojo::Callback<void(mojo::Array<ServiceReportPtr>)>&
57 callback) override;
58
59 private:
60 TrackingContext* context_;
61 StrongBinding<TestTrackedRequestService> binding_;
62
63 MOJO_DISALLOW_COPY_AND_ASSIGN(TestTrackedRequestServiceImpl);
64 };
65
66 } // namespace test
67 } // namespace mojo
68
69 #endif // SERVICES_TEST_SERVICE_TEST_REQUEST_TRACKER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698