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

Side by Side Diff: mojo/services/test_service/test_request_tracker_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: no icu Created 6 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 | 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_TEST_REQUEST_TRACKER_IMPL_H_
6 #define MOJO_SERVICES_TEST_SERVICE_TEST_REQUEST_TRACKER_IMPL_H_
7
8 #include "base/memory/weak_ptr.h"
9 #include "mojo/public/cpp/system/macros.h"
10 #include "mojo/services/test_service/test_request_tracker.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 TestRequestTrackerImpl
19 // and the master TrackedRequestService.
20 struct TrackingContext {
21 TrackingContext();
22 ~TrackingContext();
23 AllRecordsMap records;
24 std::map<uint64_t, std::string> ids_to_names;
25 uint64_t next_id;
26 };
27
28 class TestRequestTrackerImpl : public InterfaceImpl<TestRequestTracker> {
29 public:
30 TestRequestTrackerImpl(ApplicationConnection* connection,
31 TrackingContext* context);
32 virtual ~TestRequestTrackerImpl();
33
34 // TestRequestTracker.
35 virtual void RecordStats(uint64_t client_id,
36 ServiceStatsPtr stats) MOJO_OVERRIDE;
37
38 // InterfaceImpl override.
39 virtual void OnConnectionEstablished() MOJO_OVERRIDE;
40
41 private:
42 void UploaderNameCallback(uint64_t id, const mojo::String& name);
43 TrackingContext* context_;
44 base::WeakPtrFactory<TestRequestTrackerImpl> weak_factory_;
45 MOJO_DISALLOW_COPY_AND_ASSIGN(TestRequestTrackerImpl);
46 };
47
48 class TestTrackedRequestServiceImpl
49 : public InterfaceImpl<TestTrackedRequestService> {
50 public:
51 TestTrackedRequestServiceImpl(
52 ApplicationConnection* connection,
53 TrackingContext* context);
54 virtual ~TestTrackedRequestServiceImpl();
55
56 // |TestTrackedRequestService| implementation.
57 virtual void GetReport(
58 const mojo::Callback<void(mojo::Array<ServiceReportPtr>)>& callback)
59 MOJO_OVERRIDE;
60
61 private:
62 TrackingContext* context_;
63 MOJO_DISALLOW_COPY_AND_ASSIGN(TestTrackedRequestServiceImpl);
64 };
65
66 } // namespace test
67 } // namespace mojo
68
69 #endif // MOJO_SERVICES_TEST_SERVICE_TEST_REQUEST_TRACKER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698