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

Side by Side Diff: services/test_service/test_request_tracker_impl.cc

Issue 901463002: De-client TestRequestTracker (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h"
6 #include "services/test_service/test_request_tracker_impl.h" 5 #include "services/test_service/test_request_tracker_impl.h"
7 6
8 namespace mojo { 7 namespace mojo {
9 namespace test { 8 namespace test {
10 9
11 TrackingContext::TrackingContext() : next_id(1) {} 10 TrackingContext::TrackingContext() : next_id(1) {
12 TrackingContext::~TrackingContext() {} 11 }
12 TrackingContext::~TrackingContext() {
viettrungluu 2015/02/04 00:27:34 nit: blank line above
13 }
13 14
14 TestRequestTrackerImpl::TestRequestTrackerImpl(TrackingContext* context) 15 TestRequestTrackerImpl::TestRequestTrackerImpl(
15 : context_(context), weak_factory_(this) { 16 InterfaceRequest<TestRequestTracker> request,
16 } 17 TrackingContext* context)
18 : context_(context), binding_(this, request.Pass()), weak_factory_(this) {
19 }
17 20
18 TestRequestTrackerImpl::~TestRequestTrackerImpl() { 21 TestRequestTrackerImpl::~TestRequestTrackerImpl() {
19 } 22 }
20 23
21 void TestRequestTrackerImpl::RecordStats( 24 void TestRequestTrackerImpl::RecordStats(
22 uint64_t client_id, 25 uint64_t client_id,
23 ServiceStatsPtr stats) { 26 ServiceStatsPtr stats) {
24 assert(context_->ids_to_names.find(client_id) != 27 assert(context_->ids_to_names.find(client_id) !=
25 context_->ids_to_names.end()); 28 context_->ids_to_names.end());
26 context_->records[client_id].push_back(*stats); 29 context_->records[client_id].push_back(*stats);
27 } 30 }
28 31
29 void TestRequestTrackerImpl::OnConnectionEstablished() { 32 void TestRequestTrackerImpl::SetNameAndReturnId(
33 const String& service_name,
34 const Callback<void(uint64_t id)>& callback) {
30 uint64_t id = context_->next_id++; 35 uint64_t id = context_->next_id++;
31 client()->SetIdAndReturnName(id, 36 callback.Run(id);
32 base::Bind(&TestRequestTrackerImpl::UploaderNameCallback,
33 weak_factory_.GetWeakPtr(),
34 id));
35 }
36
37 void TestRequestTrackerImpl::UploaderNameCallback(
38 uint64_t id, const mojo::String& name) {
39 DCHECK(context_->ids_to_names.find(id) == context_->ids_to_names.end()); 37 DCHECK(context_->ids_to_names.find(id) == context_->ids_to_names.end());
40 context_->ids_to_names[id] = name; 38 context_->ids_to_names[id] = service_name;
41 } 39 }
42 40
43 TestTrackedRequestServiceImpl::TestTrackedRequestServiceImpl( 41 TestTrackedRequestServiceImpl::TestTrackedRequestServiceImpl(
44 TrackingContext* context) 42 TrackingContext* context)
45 : context_(context) { 43 : context_(context) {
46 } 44 }
47 45
48 TestTrackedRequestServiceImpl::~TestTrackedRequestServiceImpl() { 46 TestTrackedRequestServiceImpl::~TestTrackedRequestServiceImpl() {
49 } 47 }
50 48
(...skipping 15 matching lines...) Expand all
66 mean_health_numerator += it2->health; 64 mean_health_numerator += it2->health;
67 } 65 }
68 report->mean_health = mean_health_numerator / num_samples; 66 report->mean_health = mean_health_numerator / num_samples;
69 reports.push_back(report.Pass()); 67 reports.push_back(report.Pass());
70 } 68 }
71 callback.Run(reports.Pass()); 69 callback.Run(reports.Pass());
72 } 70 }
73 71
74 } // namespace test 72 } // namespace test
75 } // namespace mojo 73 } // namespace mojo
OLDNEW
« no previous file with comments | « services/test_service/test_request_tracker_impl.h ('k') | services/test_service/test_service_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698