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" |
(...skipping 587 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, |
608 const base::FilePath& path, | 609 const base::FilePath& path, |
609 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) | 610 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) |
610 : backend_(new Backend(path, base::MessageLoopProxy::current())), | 611 : backend_(new Backend(path, base::MessageLoopProxy::current())), |
611 blocking_task_runner_(blocking_task_runner), | 612 blocking_task_runner_(blocking_task_runner), |
612 weak_ptr_factory_(this) { | 613 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 |
613 } | 618 } |
614 | 619 |
615 GCMStoreImpl::~GCMStoreImpl() {} | 620 GCMStoreImpl::~GCMStoreImpl() {} |
616 | 621 |
617 void GCMStoreImpl::Load(const LoadCallback& callback) { | 622 void GCMStoreImpl::Load(const LoadCallback& callback) { |
618 blocking_task_runner_->PostTask( | 623 blocking_task_runner_->PostTask( |
619 FROM_HERE, | 624 FROM_HERE, |
620 base::Bind(&GCMStoreImpl::Backend::Load, | 625 base::Bind(&GCMStoreImpl::Backend::Load, |
621 backend_, | 626 backend_, |
622 base::Bind(&GCMStoreImpl::LoadContinuation, | 627 base::Bind(&GCMStoreImpl::LoadContinuation, |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 removed_message_counts.begin(); | 835 removed_message_counts.begin(); |
831 iter != removed_message_counts.end(); ++iter) { | 836 iter != removed_message_counts.end(); ++iter) { |
832 DCHECK_NE(app_message_counts_.count(iter->first), 0U); | 837 DCHECK_NE(app_message_counts_.count(iter->first), 0U); |
833 app_message_counts_[iter->first] -= iter->second; | 838 app_message_counts_[iter->first] -= iter->second; |
834 DCHECK_GE(app_message_counts_[iter->first], 0); | 839 DCHECK_GE(app_message_counts_[iter->first], 0); |
835 } | 840 } |
836 callback.Run(true); | 841 callback.Run(true); |
837 } | 842 } |
838 | 843 |
839 } // namespace gcm | 844 } // namespace gcm |
OLD | NEW |