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

Side by Side Diff: google_apis/gcm/engine/gcm_store_impl.cc

Issue 1547233002: Convert Pass()→std::move() in //google_apis (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 "google_apis/gcm/engine/gcm_store_impl.h" 5 #include "google_apis/gcm/engine/gcm_store_impl.h"
6 6
7 #include <utility>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/callback.h" 10 #include "base/callback.h"
9 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
11 #include "base/logging.h" 13 #include "base/logging.h"
12 #include "base/macros.h" 14 #include "base/macros.h"
13 #include "base/metrics/histogram_macros.h" 15 #include "base/metrics/histogram_macros.h"
14 #include "base/profiler/scoped_tracker.h" 16 #include "base/profiler/scoped_tracker.h"
15 #include "base/sequenced_task_runner.h" 17 #include "base/sequenced_task_runner.h"
16 #include "base/stl_util.h" 18 #include "base/stl_util.h"
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 266
265 scoped_ptr<leveldb::DB> db_; 267 scoped_ptr<leveldb::DB> db_;
266 }; 268 };
267 269
268 GCMStoreImpl::Backend::Backend( 270 GCMStoreImpl::Backend::Backend(
269 const base::FilePath& path, 271 const base::FilePath& path,
270 scoped_refptr<base::SequencedTaskRunner> foreground_task_runner, 272 scoped_refptr<base::SequencedTaskRunner> foreground_task_runner,
271 scoped_ptr<Encryptor> encryptor) 273 scoped_ptr<Encryptor> encryptor)
272 : path_(path), 274 : path_(path),
273 foreground_task_runner_(foreground_task_runner), 275 foreground_task_runner_(foreground_task_runner),
274 encryptor_(encryptor.Pass()) { 276 encryptor_(std::move(encryptor)) {}
275 }
276 277
277 GCMStoreImpl::Backend::~Backend() {} 278 GCMStoreImpl::Backend::~Backend() {}
278 279
279 LoadStatus GCMStoreImpl::Backend::OpenStoreAndLoadData(StoreOpenMode open_mode, 280 LoadStatus GCMStoreImpl::Backend::OpenStoreAndLoadData(StoreOpenMode open_mode,
280 LoadResult* result) { 281 LoadResult* result) {
281 LoadStatus load_status; 282 LoadStatus load_status;
282 if (db_.get()) { 283 if (db_.get()) {
283 LOG(ERROR) << "Attempting to reload open database."; 284 LOG(ERROR) << "Attempting to reload open database.";
284 return RELOADING_OPEN_STORE; 285 return RELOADING_OPEN_STORE;
285 } 286 }
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 1159
1159 return true; 1160 return true;
1160 } 1161 }
1161 1162
1162 GCMStoreImpl::GCMStoreImpl( 1163 GCMStoreImpl::GCMStoreImpl(
1163 const base::FilePath& path, 1164 const base::FilePath& path,
1164 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, 1165 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner,
1165 scoped_ptr<Encryptor> encryptor) 1166 scoped_ptr<Encryptor> encryptor)
1166 : backend_(new Backend(path, 1167 : backend_(new Backend(path,
1167 base::ThreadTaskRunnerHandle::Get(), 1168 base::ThreadTaskRunnerHandle::Get(),
1168 encryptor.Pass())), 1169 std::move(encryptor))),
1169 blocking_task_runner_(blocking_task_runner), 1170 blocking_task_runner_(blocking_task_runner),
1170 weak_ptr_factory_(this) { 1171 weak_ptr_factory_(this) {}
1171 }
1172 1172
1173 GCMStoreImpl::~GCMStoreImpl() {} 1173 GCMStoreImpl::~GCMStoreImpl() {}
1174 1174
1175 void GCMStoreImpl::Load(StoreOpenMode open_mode, const LoadCallback& callback) { 1175 void GCMStoreImpl::Load(StoreOpenMode open_mode, const LoadCallback& callback) {
1176 blocking_task_runner_->PostTask( 1176 blocking_task_runner_->PostTask(
1177 FROM_HERE, 1177 FROM_HERE,
1178 base::Bind(&GCMStoreImpl::Backend::Load, 1178 base::Bind(&GCMStoreImpl::Backend::Load,
1179 backend_, 1179 backend_,
1180 open_mode, 1180 open_mode,
1181 base::Bind(&GCMStoreImpl::LoadContinuation, 1181 base::Bind(&GCMStoreImpl::LoadContinuation,
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 callback)); 1423 callback));
1424 } 1424 }
1425 1425
1426 void GCMStoreImpl::LoadContinuation(const LoadCallback& callback, 1426 void GCMStoreImpl::LoadContinuation(const LoadCallback& callback,
1427 scoped_ptr<LoadResult> result) { 1427 scoped_ptr<LoadResult> result) {
1428 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. 1428 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed.
1429 tracked_objects::ScopedTracker tracking_profile( 1429 tracked_objects::ScopedTracker tracking_profile(
1430 FROM_HERE_WITH_EXPLICIT_FUNCTION( 1430 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1431 "477117 GCMStoreImpl::LoadContinuation")); 1431 "477117 GCMStoreImpl::LoadContinuation"));
1432 if (!result->success) { 1432 if (!result->success) {
1433 callback.Run(result.Pass()); 1433 callback.Run(std::move(result));
1434 return; 1434 return;
1435 } 1435 }
1436 int num_throttled_apps = 0; 1436 int num_throttled_apps = 0;
1437 for (OutgoingMessageMap::const_iterator 1437 for (OutgoingMessageMap::const_iterator
1438 iter = result->outgoing_messages.begin(); 1438 iter = result->outgoing_messages.begin();
1439 iter != result->outgoing_messages.end(); ++iter) { 1439 iter != result->outgoing_messages.end(); ++iter) {
1440 const mcs_proto::DataMessageStanza* data_message = 1440 const mcs_proto::DataMessageStanza* data_message =
1441 reinterpret_cast<mcs_proto::DataMessageStanza*>(iter->second.get()); 1441 reinterpret_cast<mcs_proto::DataMessageStanza*>(iter->second.get());
1442 DCHECK(!data_message->category().empty()); 1442 DCHECK(!data_message->category().empty());
1443 if (app_message_counts_.count(data_message->category()) == 0) 1443 if (app_message_counts_.count(data_message->category()) == 0)
1444 app_message_counts_[data_message->category()] = 1; 1444 app_message_counts_[data_message->category()] = 1;
1445 else 1445 else
1446 app_message_counts_[data_message->category()]++; 1446 app_message_counts_[data_message->category()]++;
1447 if (app_message_counts_[data_message->category()] == kMessagesPerAppLimit) 1447 if (app_message_counts_[data_message->category()] == kMessagesPerAppLimit)
1448 num_throttled_apps++; 1448 num_throttled_apps++;
1449 } 1449 }
1450 UMA_HISTOGRAM_COUNTS("GCM.NumThrottledApps", num_throttled_apps); 1450 UMA_HISTOGRAM_COUNTS("GCM.NumThrottledApps", num_throttled_apps);
1451 callback.Run(result.Pass()); 1451 callback.Run(std::move(result));
1452 } 1452 }
1453 1453
1454 void GCMStoreImpl::AddOutgoingMessageContinuation( 1454 void GCMStoreImpl::AddOutgoingMessageContinuation(
1455 const UpdateCallback& callback, 1455 const UpdateCallback& callback,
1456 const std::string& app_id, 1456 const std::string& app_id,
1457 bool success) { 1457 bool success) {
1458 if (!success) { 1458 if (!success) {
1459 DCHECK(app_message_counts_[app_id] > 0); 1459 DCHECK(app_message_counts_[app_id] > 0);
1460 app_message_counts_[app_id]--; 1460 app_message_counts_[app_id]--;
1461 } 1461 }
(...skipping 12 matching lines...) Expand all
1474 removed_message_counts.begin(); 1474 removed_message_counts.begin();
1475 iter != removed_message_counts.end(); ++iter) { 1475 iter != removed_message_counts.end(); ++iter) {
1476 DCHECK_NE(app_message_counts_.count(iter->first), 0U); 1476 DCHECK_NE(app_message_counts_.count(iter->first), 0U);
1477 app_message_counts_[iter->first] -= iter->second; 1477 app_message_counts_[iter->first] -= iter->second;
1478 DCHECK_GE(app_message_counts_[iter->first], 0); 1478 DCHECK_GE(app_message_counts_[iter->first], 0);
1479 } 1479 }
1480 callback.Run(true); 1480 callback.Run(true);
1481 } 1481 }
1482 1482
1483 } // namespace gcm 1483 } // namespace gcm
OLDNEW
« no previous file with comments | « google_apis/gcm/engine/fake_connection_handler.cc ('k') | google_apis/gcm/engine/gcm_store_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698