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

Side by Side Diff: mojo/services/test_service/test_request_tracker_client_impl.cc

Issue 687433002: Remove mojo/shell and (most) service implementations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove mojo/gles2, disable mojo apps in component build Created 6 years, 1 month 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 #include "mojo/services/test_service/test_request_tracker_client_impl.h"
6
7 namespace mojo {
8 namespace test {
9
10 TestRequestTrackerClientImpl::TestRequestTrackerClientImpl(
11 TestRequestTrackerPtr tracker,
12 const std::string& service_name,
13 const mojo::Callback<void()>& callback)
14 : id_(0),
15 requests_since_upload_(0),
16 service_name_(service_name),
17 tracker_(tracker.Pass()),
18 tracking_connected_callback_(callback) {
19 tracker_.set_client(this);
20 }
21
22 TestRequestTrackerClientImpl::~TestRequestTrackerClientImpl() {
23 }
24
25 void TestRequestTrackerClientImpl::RecordNewRequest() {
26 requests_since_upload_++;
27 if (id_ == kInvalidId)
28 return;
29 SendStats();
30 }
31
32 void TestRequestTrackerClientImpl::SendStats() {
33 ServiceStatsPtr stats(ServiceStats::New());
34 stats->num_new_requests = requests_since_upload_;
35 stats->health = 0.7;
36 tracker_->RecordStats(id_, stats.Pass());
37 requests_since_upload_ = 0;
38 }
39
40 void TestRequestTrackerClientImpl::SetIdAndReturnName(
41 uint64_t id,
42 const mojo::Callback<void(mojo::String)>& callback) {
43 assert(id != kInvalidId);
44 assert(id_ == kInvalidId);
45 id_ = id;
46 callback.Run(service_name_);
47 tracking_connected_callback_.Run();
48 if (requests_since_upload_ == 0)
49 return;
50 SendStats();
51 }
52
53 } // namespace test
54 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/test_service/test_request_tracker_client_impl.h ('k') | mojo/services/test_service/test_request_tracker_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698