| 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, | |
| 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 |