| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/contacts/fake_contact_store.h" | 5 #include "chrome/browser/chromeos/contacts/fake_contact_store.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "chrome/browser/chromeos/contacts/contact.pb.h" | 9 #include "chrome/browser/chromeos/contacts/contact.pb.h" |
| 10 #include "chrome/browser/chromeos/contacts/contact_store_observer.h" | 10 #include "chrome/browser/chromeos/contacts/contact_store_observer.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 : permit_store_creation_(true) { | 71 : permit_store_creation_(true) { |
| 72 } | 72 } |
| 73 | 73 |
| 74 FakeContactStoreFactory::~FakeContactStoreFactory() { | 74 FakeContactStoreFactory::~FakeContactStoreFactory() { |
| 75 CHECK(stores_.empty()); | 75 CHECK(stores_.empty()); |
| 76 } | 76 } |
| 77 | 77 |
| 78 FakeContactStore* FakeContactStoreFactory::GetContactStoreForProfile( | 78 FakeContactStore* FakeContactStoreFactory::GetContactStoreForProfile( |
| 79 Profile* profile) { | 79 Profile* profile) { |
| 80 CHECK(profile); | 80 CHECK(profile); |
| 81 return stores_[profile]; | 81 ProfileStoreMap::const_iterator it = stores_.find(profile); |
| 82 return it != stores_.end() ? it->second : NULL; |
| 82 } | 83 } |
| 83 | 84 |
| 84 void FakeContactStoreFactory::RemoveStore(FakeContactStore* store) { | 85 void FakeContactStoreFactory::RemoveStore(FakeContactStore* store) { |
| 85 CHECK(store); | 86 CHECK(store); |
| 86 for (ProfileStoreMap::iterator it = stores_.begin(); | 87 for (ProfileStoreMap::iterator it = stores_.begin(); |
| 87 it != stores_.end(); ++it) { | 88 it != stores_.end(); ++it) { |
| 88 if (it->second == store) { | 89 if (it->second == store) { |
| 89 stores_.erase(it); | 90 stores_.erase(it); |
| 90 return; | 91 return; |
| 91 } | 92 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 103 CHECK(profile); | 104 CHECK(profile); |
| 104 CHECK(CanCreateContactStoreForProfile(profile)); | 105 CHECK(CanCreateContactStoreForProfile(profile)); |
| 105 FakeContactStore* store = new FakeContactStore(this); | 106 FakeContactStore* store = new FakeContactStore(this); |
| 106 CHECK(stores_.insert(std::make_pair(profile, store)).second) | 107 CHECK(stores_.insert(std::make_pair(profile, store)).second) |
| 107 << "Got request to create second FakeContactStore for profile " | 108 << "Got request to create second FakeContactStore for profile " |
| 108 << profile << " (" << profile->GetProfileName() << ")"; | 109 << profile << " (" << profile->GetProfileName() << ")"; |
| 109 return store; | 110 return store; |
| 110 } | 111 } |
| 111 | 112 |
| 112 } // namespace contacts | 113 } // namespace contacts |
| OLD | NEW |