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 MOJO_SERVICES_TEST_SERVICE_TEST_REQUEST_TRACKER_IMPL_H_
6 #define MOJO_SERVICES_TEST_SERVICE_TEST_REQUEST_TRACKER_IMPL_H_
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"
13 class ApplicationConnection
;
16 typedef std::map
<uint64_t, std::vector
<ServiceStats
> > AllRecordsMap
;
18 // Shared state between all instances of TestRequestTrackerImpl
19 // and the master TrackedRequestService.
20 struct TrackingContext
{
23 AllRecordsMap records
;
24 std::map
<uint64_t, std::string
> ids_to_names
;
28 class TestRequestTrackerImpl
: public InterfaceImpl
<TestRequestTracker
> {
30 explicit TestRequestTrackerImpl(TrackingContext
* context
);
31 virtual ~TestRequestTrackerImpl();
33 // TestRequestTracker.
34 virtual void RecordStats(uint64_t client_id
,
35 ServiceStatsPtr stats
) MOJO_OVERRIDE
;
37 // InterfaceImpl override.
38 virtual void OnConnectionEstablished() MOJO_OVERRIDE
;
41 void UploaderNameCallback(uint64_t id
, const mojo::String
& name
);
42 TrackingContext
* context_
;
43 base::WeakPtrFactory
<TestRequestTrackerImpl
> weak_factory_
;
44 MOJO_DISALLOW_COPY_AND_ASSIGN(TestRequestTrackerImpl
);
47 class TestTrackedRequestServiceImpl
48 : public InterfaceImpl
<TestTrackedRequestService
> {
50 explicit TestTrackedRequestServiceImpl(TrackingContext
* context
);
51 virtual ~TestTrackedRequestServiceImpl();
53 // |TestTrackedRequestService| implementation.
54 virtual void GetReport(
55 const mojo::Callback
<void(mojo::Array
<ServiceReportPtr
>)>& callback
)
59 TrackingContext
* context_
;
60 MOJO_DISALLOW_COPY_AND_ASSIGN(TestTrackedRequestServiceImpl
);
66 #endif // MOJO_SERVICES_TEST_SERVICE_TEST_REQUEST_TRACKER_IMPL_H_