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/chrome/browser/browser_state/chrome_browser_state_manager_impl.h" | 5 #include "ios/chrome/browser/browser_state/chrome_browser_state_manager_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 134 |
135 ios::ChromeBrowserState* ChromeBrowserStateManagerImpl::GetBrowserState( | 135 ios::ChromeBrowserState* ChromeBrowserStateManagerImpl::GetBrowserState( |
136 const base::FilePath& path) { | 136 const base::FilePath& path) { |
137 // If the browser state is already loaded, just return it. | 137 // If the browser state is already loaded, just return it. |
138 auto iter = browser_states_.find(path); | 138 auto iter = browser_states_.find(path); |
139 if (iter != browser_states_.end()) { | 139 if (iter != browser_states_.end()) { |
140 DCHECK(iter->second.get()); | 140 DCHECK(iter->second.get()); |
141 return iter->second.get(); | 141 return iter->second.get(); |
142 } | 142 } |
143 | 143 |
144 scoped_ptr<ChromeBrowserStateImpl> browser_state_impl( | 144 std::unique_ptr<ChromeBrowserStateImpl> browser_state_impl( |
145 new ChromeBrowserStateImpl(path)); | 145 new ChromeBrowserStateImpl(path)); |
146 DCHECK(!browser_state_impl->IsOffTheRecord()); | 146 DCHECK(!browser_state_impl->IsOffTheRecord()); |
147 | 147 |
148 std::pair<ChromeBrowserStateImplPathMap::iterator, bool> insert_result = | 148 std::pair<ChromeBrowserStateImplPathMap::iterator, bool> insert_result = |
149 browser_states_.insert( | 149 browser_states_.insert( |
150 std::make_pair(path, std::move(browser_state_impl))); | 150 std::make_pair(path, std::move(browser_state_impl))); |
151 DCHECK(insert_result.second); | 151 DCHECK(insert_result.second); |
152 DCHECK(insert_result.first != browser_states_.end()); | 152 DCHECK(insert_result.first != browser_states_.end()); |
153 | 153 |
154 DoFinalInit(insert_result.first->second.get()); | 154 DoFinalInit(insert_result.first->second.get()); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 cache->GetIndexOfBrowserStateWithPath(browser_state->GetStatePath()); | 245 cache->GetIndexOfBrowserStateWithPath(browser_state->GetStatePath()); |
246 if (browser_state_index != std::string::npos) { | 246 if (browser_state_index != std::string::npos) { |
247 // The BrowserStateInfoCache's info must match the Signin Manager. | 247 // The BrowserStateInfoCache's info must match the Signin Manager. |
248 cache->SetAuthInfoOfBrowserStateAtIndex(browser_state_index, | 248 cache->SetAuthInfoOfBrowserStateAtIndex(browser_state_index, |
249 account_info.gaia, username); | 249 account_info.gaia, username); |
250 return; | 250 return; |
251 } | 251 } |
252 cache->AddBrowserState(browser_state->GetStatePath(), account_info.gaia, | 252 cache->AddBrowserState(browser_state->GetStatePath(), account_info.gaia, |
253 username); | 253 username); |
254 } | 254 } |
OLD | NEW |