Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ios/public/provider/chrome/browser/test_chrome_browser_provider.h" | 5 #include "ios/public/provider/chrome/browser/test_chrome_browser_provider.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ptr_util.h" | |
| 8 #include "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service .h" | 9 #include "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service .h" |
| 9 #import "ios/public/provider/chrome/browser/test_updatable_resource_provider.h" | 10 #import "ios/public/provider/chrome/browser/test_updatable_resource_provider.h" |
| 10 | 11 |
| 11 namespace ios { | 12 namespace ios { |
| 12 | 13 |
| 13 TestChromeBrowserProvider::TestChromeBrowserProvider() | 14 TestChromeBrowserProvider::TestChromeBrowserProvider() |
| 14 : chrome_identity_service_(new ios::FakeChromeIdentityService), | 15 : test_updatable_resource_provider_(new TestUpdatableResourceProvider) {} |
| 15 test_updatable_resource_provider_(new TestUpdatableResourceProvider) {} | |
| 16 | 16 |
| 17 TestChromeBrowserProvider::~TestChromeBrowserProvider() {} | 17 TestChromeBrowserProvider::~TestChromeBrowserProvider() {} |
| 18 | 18 |
| 19 // static | 19 // static |
| 20 TestChromeBrowserProvider* TestChromeBrowserProvider::GetTestProvider() { | 20 TestChromeBrowserProvider* TestChromeBrowserProvider::GetTestProvider() { |
| 21 ChromeBrowserProvider* provider = GetChromeBrowserProvider(); | 21 ChromeBrowserProvider* provider = GetChromeBrowserProvider(); |
| 22 DCHECK(provider); | 22 DCHECK(provider); |
| 23 return static_cast<TestChromeBrowserProvider*>(provider); | 23 return static_cast<TestChromeBrowserProvider*>(provider); |
| 24 } | 24 } |
| 25 | 25 |
| 26 void TestChromeBrowserProvider::SetChromeIdentityService( | |
| 27 std::unique_ptr<ChromeIdentityService> service) { | |
| 28 chrome_identity_service_.swap(service); | |
|
rohitrao (ping after 24h)
2016/08/29 14:16:36
Why swap() instead of reset()?
bzanotti
2016/08/29 14:31:47
AFAIK, reset() cannot be used with two unique_ptr.
| |
| 29 } | |
| 30 | |
| 26 ChromeIdentityService* TestChromeBrowserProvider::GetChromeIdentityService() { | 31 ChromeIdentityService* TestChromeBrowserProvider::GetChromeIdentityService() { |
| 32 if (!chrome_identity_service_) { | |
| 33 SetChromeIdentityService(base::WrapUnique(new FakeChromeIdentityService())); | |
| 34 } | |
| 27 return chrome_identity_service_.get(); | 35 return chrome_identity_service_.get(); |
| 28 } | 36 } |
| 29 | 37 |
| 30 UpdatableResourceProvider* | 38 UpdatableResourceProvider* |
| 31 TestChromeBrowserProvider::GetUpdatableResourceProvider() { | 39 TestChromeBrowserProvider::GetUpdatableResourceProvider() { |
| 32 return test_updatable_resource_provider_.get(); | 40 return test_updatable_resource_provider_.get(); |
| 33 } | 41 } |
| 34 | 42 |
| 35 } // namespace ios | 43 } // namespace ios |
| OLD | NEW |