OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/arc/intent_helper/activity_icon_loader.h" | 5 #include "components/arc/intent_helper/activity_icon_loader.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <tuple> | 9 #include <tuple> |
10 #include <utility> | 10 #include <utility> |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 if (activities_to_fetch.empty()) { | 85 if (activities_to_fetch.empty()) { |
86 // If there's nothing to fetch, run the callback now. | 86 // If there's nothing to fetch, run the callback now. |
87 cb.Run(std::move(result)); | 87 cb.Run(std::move(result)); |
88 return GetResult::SUCCEEDED_SYNC; | 88 return GetResult::SUCCEEDED_SYNC; |
89 } | 89 } |
90 | 90 |
91 ArcIntentHelperBridge::GetResult error_code; | 91 ArcIntentHelperBridge::GetResult error_code; |
92 mojom::IntentHelperInstance* instance = | 92 auto* instance = ArcIntentHelperBridge::GetIntentHelperInstanceWithErrorCode( |
93 ArcIntentHelperBridge::GetIntentHelperInstanceWithErrorCode( | 93 "RequestActivityIcons", kMinInstanceVersion, &error_code); |
94 kMinInstanceVersion, &error_code); | |
95 if (!instance) { | 94 if (!instance) { |
96 // The mojo channel is not yet ready (or not supported at all). Run the | 95 // The mojo channel is not yet ready (or not supported at all). Run the |
97 // callback with |result| that could be empty. | 96 // callback with |result| that could be empty. |
98 cb.Run(std::move(result)); | 97 cb.Run(std::move(result)); |
99 switch (error_code) { | 98 switch (error_code) { |
100 case ArcIntentHelperBridge::GetResult::FAILED_ARC_NOT_READY: | 99 case ArcIntentHelperBridge::GetResult::FAILED_ARC_NOT_READY: |
101 return GetResult(GetResult::FAILED_ARC_NOT_READY); | 100 return GetResult(GetResult::FAILED_ARC_NOT_READY); |
102 case ArcIntentHelperBridge::GetResult::FAILED_ARC_NOT_SUPPORTED: | 101 case ArcIntentHelperBridge::GetResult::FAILED_ARC_NOT_SUPPORTED: |
103 return GetResult(GetResult::FAILED_ARC_NOT_SUPPORTED); | 102 return GetResult(GetResult::FAILED_ARC_NOT_SUPPORTED); |
104 } | 103 } |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 cached_icons_.erase(kv.first); | 197 cached_icons_.erase(kv.first); |
199 cached_icons_.insert(std::make_pair(kv.first, kv.second)); | 198 cached_icons_.insert(std::make_pair(kv.first, kv.second)); |
200 } | 199 } |
201 | 200 |
202 // Merge the results that were obtained from cache before doing IPC. | 201 // Merge the results that were obtained from cache before doing IPC. |
203 result->insert(cached_result->begin(), cached_result->end()); | 202 result->insert(cached_result->begin(), cached_result->end()); |
204 cb.Run(std::move(result)); | 203 cb.Run(std::move(result)); |
205 } | 204 } |
206 | 205 |
207 } // namespace arc | 206 } // namespace arc |
OLD | NEW |