OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 <algorithm> | 5 #include <algorithm> |
6 #include <string> | 6 #include <string> |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 // with any other namespace. | 44 // with any other namespace. |
45 if (!MapContainsValue(providers_, provider)) | 45 if (!MapContainsValue(providers_, provider)) |
46 provider->AddObserver(this); | 46 provider->AddObserver(this); |
47 | 47 |
48 providers_[name_space] = provider; | 48 providers_[name_space] = provider; |
49 } | 49 } |
50 | 50 |
51 void OfflineContentAggregator::UnregisterProvider( | 51 void OfflineContentAggregator::UnregisterProvider( |
52 const std::string& name_space) { | 52 const std::string& name_space) { |
53 auto provider_it = providers_.find(name_space); | 53 auto provider_it = providers_.find(name_space); |
54 if (provider_it == providers_.end()) | |
David Trainor- moved to gerrit
2017/04/19 22:45:12
Ty!
| |
55 return; | |
54 | 56 |
55 OfflineContentProvider* provider = provider_it->second; | 57 OfflineContentProvider* provider = provider_it->second; |
56 providers_.erase(provider_it); | 58 providers_.erase(provider_it); |
57 | 59 |
58 // Only clean up the connection to the provider if the provider isn't | 60 // Only clean up the connection to the provider if the provider isn't |
59 // associated with any other namespace. | 61 // associated with any other namespace. |
60 if (!MapContainsValue(providers_, provider)) { | 62 if (!MapContainsValue(providers_, provider)) { |
61 provider->RemoveObserver(this); | 63 provider->RemoveObserver(this); |
62 pending_actions_.erase(provider); | 64 pending_actions_.erase(provider); |
63 } | 65 } |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
268 | 270 |
269 void OfflineContentAggregator::RunIfReady(OfflineContentProvider* provider, | 271 void OfflineContentAggregator::RunIfReady(OfflineContentProvider* provider, |
270 const base::Closure& action) { | 272 const base::Closure& action) { |
271 if (provider->AreItemsAvailable()) | 273 if (provider->AreItemsAvailable()) |
272 action.Run(); | 274 action.Run(); |
273 else | 275 else |
274 pending_actions_[provider].push_back(action); | 276 pending_actions_[provider].push_back(action); |
275 } | 277 } |
276 | 278 |
277 } // namespace offline_items_collection | 279 } // namespace offline_items_collection |
OLD | NEW |