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

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

Issue 1539863002: Convert Pass()→std::move() in mojo/services/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix missing forward declare that was masked by pre-existing incorrect #include ordering. Created 5 years 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 "mojo/services/test_service/tracked_service.h" 5 #include "mojo/services/test_service/tracked_service.h"
6 6
7 #include <utility>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 10
9 namespace mojo { 11 namespace mojo {
10 namespace test { 12 namespace test {
11 13
12 TrackedService::TrackedService(TestRequestTrackerPtr tracker, 14 TrackedService::TrackedService(TestRequestTrackerPtr tracker,
13 const std::string& service_name, 15 const std::string& service_name,
14 const mojo::Callback<void()>& callback) 16 const mojo::Callback<void()>& callback)
15 : id_(0u), 17 : id_(0u),
16 requests_since_upload_(0u), 18 requests_since_upload_(0u),
17 service_name_(service_name), 19 service_name_(service_name),
18 tracker_(tracker.Pass()), 20 tracker_(std::move(tracker)),
19 tracking_connected_callback_(callback) { 21 tracking_connected_callback_(callback) {
20 tracker_->SetNameAndReturnId( 22 tracker_->SetNameAndReturnId(
21 service_name, base::Bind(&TrackedService::SetId, base::Unretained(this))); 23 service_name, base::Bind(&TrackedService::SetId, base::Unretained(this)));
22 } 24 }
23 25
24 TrackedService::~TrackedService() { 26 TrackedService::~TrackedService() {
25 } 27 }
26 28
27 void TrackedService::RecordNewRequest() { 29 void TrackedService::RecordNewRequest() {
28 requests_since_upload_++; 30 requests_since_upload_++;
29 if (id_ == 0u) 31 if (id_ == 0u)
30 return; 32 return;
31 SendStats(); 33 SendStats();
32 } 34 }
33 35
34 void TrackedService::SendStats() { 36 void TrackedService::SendStats() {
35 ServiceStatsPtr stats(ServiceStats::New()); 37 ServiceStatsPtr stats(ServiceStats::New());
36 stats->num_new_requests = requests_since_upload_; 38 stats->num_new_requests = requests_since_upload_;
37 stats->health = 0.7; 39 stats->health = 0.7;
38 tracker_->RecordStats(id_, stats.Pass()); 40 tracker_->RecordStats(id_, std::move(stats));
39 requests_since_upload_ = 0u; 41 requests_since_upload_ = 0u;
40 } 42 }
41 43
42 void TrackedService::SetId(uint64_t id) { 44 void TrackedService::SetId(uint64_t id) {
43 assert(id != 0u); 45 assert(id != 0u);
44 assert(id_ == 0u); 46 assert(id_ == 0u);
45 id_ = id; 47 id_ = id;
46 tracking_connected_callback_.Run(); 48 tracking_connected_callback_.Run();
47 if (requests_since_upload_ == 0u) 49 if (requests_since_upload_ == 0u)
48 return; 50 return;
49 SendStats(); 51 SendStats();
50 } 52 }
51 53
52 } // namespace test 54 } // namespace test
53 } // namespace mojo 55 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/test_service/test_time_service_impl.cc ('k') | mojo/services/tracing/public/cpp/trace_provider_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698