| Flutter iOS Embedder |

connection_collection.mm
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import "flutter/shell/platform/darwin/ios/framework/Source/connection_collection.h"
6
7 #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
8
9 FLUTTER_ASSERT_ARC
10
11 namespace flutter {
12 ConnectionCollection::Connection ConnectionCollection::AquireConnection(const std::string& name) {
13 Connection nextConnection = ++counter_;
14 connections_[name] = nextConnection;
15 return nextConnection;
16 }
17
18 std::string ConnectionCollection::CleanupConnection(ConnectionCollection::Connection connection) {
19 if (connection > 0) {
20 std::string channel;
21 for (auto& keyValue : connections_) {
22 if (keyValue.second == connection) {
23 channel = keyValue.first;
24 break;
25 }
26 }
27 if (channel.length() > 0) {
28 connections_.erase(channel);
29 return channel;
30 }
31 }
32 return "";
33 }
34
35 bool ConnectionCollection::IsValidConnection(ConnectionCollection::Connection connection) {
36 return connection > 0;
37 }
38
39 ConnectionCollection::Connection ConnectionCollection::MakeErrorConnection(int errCode) {
40 if (errCode < 0) {
41 return -1 * errCode;
42 }
43 return errCode;
44 }
45
46 } // namespace flutter
flutter::ConnectionCollection::Connection
int64_t Connection
Definition: connection_collection.h:17
connection_collection.h
FlutterMacros.h
flutter::ConnectionCollection::CleanupConnection
std::string CleanupConnection(Connection connection)
Definition: connection_collection.mm:18
flutter::ConnectionCollection::MakeErrorConnection
static Connection MakeErrorConnection(int errCode)
Definition: connection_collection.mm:39
flutter
Definition: accessibility_bridge.h:28
flutter::ConnectionCollection::IsValidConnection
static bool IsValidConnection(Connection connection)
Definition: connection_collection.mm:35
FLUTTER_ASSERT_ARC
Definition: FlutterChannelKeyResponder.mm:13
flutter::ConnectionCollection::AquireConnection
Connection AquireConnection(const std::string &name)
Definition: connection_collection.mm:12