OLD | NEW |
---|---|
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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/message_loop/message_loop_proxy.h" | 13 #include "base/message_loop/message_loop_proxy.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/sequenced_task_runner.h" | 15 #include "base/sequenced_task_runner.h" |
16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
18 #include "base/strings/string_piece.h" | 18 #include "base/strings/string_piece.h" |
19 #include "base/tracked_objects.h" | 19 #include "base/tracked_objects.h" |
20 #include "components/os_crypt/os_crypt.h" | 20 #include "components/os_crypt/os_crypt.h" |
jianli
2014/04/10 18:38:12
This can be removed now.
Nicolas Zea
2014/04/10 18:54:48
It's needed for the actual encryption/decryption
fgorski
2014/04/10 19:01:15
Correct. It has to stay.
| |
21 #include "google_apis/gcm/base/mcs_message.h" | 21 #include "google_apis/gcm/base/mcs_message.h" |
22 #include "google_apis/gcm/base/mcs_util.h" | 22 #include "google_apis/gcm/base/mcs_util.h" |
23 #include "google_apis/gcm/protocol/mcs.pb.h" | 23 #include "google_apis/gcm/protocol/mcs.pb.h" |
24 #include "third_party/leveldatabase/src/include/leveldb/db.h" | 24 #include "third_party/leveldatabase/src/include/leveldb/db.h" |
25 | 25 |
26 namespace gcm { | 26 namespace gcm { |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 // Limit to the number of outstanding messages per app. | 30 // Limit to the number of outstanding messages per app. |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
598 LOG(ERROR) << "Failed to restore last checkin time. Using default = 0."; | 598 LOG(ERROR) << "Failed to restore last checkin time. Using default = 0."; |
599 | 599 |
600 // In case we cannot read last checkin time, we default it to 0, as we don't | 600 // In case we cannot read last checkin time, we default it to 0, as we don't |
601 // want that situation to cause the whole load to fail. | 601 // want that situation to cause the whole load to fail. |
602 *last_checkin_time = base::Time::FromInternalValue(time_internal); | 602 *last_checkin_time = base::Time::FromInternalValue(time_internal); |
603 | 603 |
604 return true; | 604 return true; |
605 } | 605 } |
606 | 606 |
607 GCMStoreImpl::GCMStoreImpl( | 607 GCMStoreImpl::GCMStoreImpl( |
608 bool use_mock_keychain, | |
609 const base::FilePath& path, | 608 const base::FilePath& path, |
610 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) | 609 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) |
611 : backend_(new Backend(path, base::MessageLoopProxy::current())), | 610 : backend_(new Backend(path, base::MessageLoopProxy::current())), |
612 blocking_task_runner_(blocking_task_runner), | 611 blocking_task_runner_(blocking_task_runner), |
613 weak_ptr_factory_(this) { | 612 weak_ptr_factory_(this) { |
614 // On OSX, prevent the Keychain permissions popup during unit tests. | |
615 #if defined(OS_MACOSX) | |
616 OSCrypt::UseMockKeychain(use_mock_keychain); | |
617 #endif | |
618 } | 613 } |
619 | 614 |
620 GCMStoreImpl::~GCMStoreImpl() {} | 615 GCMStoreImpl::~GCMStoreImpl() {} |
621 | 616 |
622 void GCMStoreImpl::Load(const LoadCallback& callback) { | 617 void GCMStoreImpl::Load(const LoadCallback& callback) { |
623 blocking_task_runner_->PostTask( | 618 blocking_task_runner_->PostTask( |
624 FROM_HERE, | 619 FROM_HERE, |
625 base::Bind(&GCMStoreImpl::Backend::Load, | 620 base::Bind(&GCMStoreImpl::Backend::Load, |
626 backend_, | 621 backend_, |
627 base::Bind(&GCMStoreImpl::LoadContinuation, | 622 base::Bind(&GCMStoreImpl::LoadContinuation, |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
835 removed_message_counts.begin(); | 830 removed_message_counts.begin(); |
836 iter != removed_message_counts.end(); ++iter) { | 831 iter != removed_message_counts.end(); ++iter) { |
837 DCHECK_NE(app_message_counts_.count(iter->first), 0U); | 832 DCHECK_NE(app_message_counts_.count(iter->first), 0U); |
838 app_message_counts_[iter->first] -= iter->second; | 833 app_message_counts_[iter->first] -= iter->second; |
839 DCHECK_GE(app_message_counts_[iter->first], 0); | 834 DCHECK_GE(app_message_counts_[iter->first], 0); |
840 } | 835 } |
841 callback.Run(true); | 836 callback.Run(true); |
842 } | 837 } |
843 | 838 |
844 } // namespace gcm | 839 } // namespace gcm |
OLD | NEW |