Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / legacy-libs / grpc-cloned / deps / grpc / src / core / ext / filters / client_channel / resolver.cc
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18
19 #include <grpc/support/port_platform.h>
20
21 #include "src/core/ext/filters/client_channel/resolver.h"
22 #include "src/core/lib/iomgr/combiner.h"
23
24 grpc_core::DebugOnlyTraceFlag grpc_trace_resolver_refcount(false,
25                                                            "resolver_refcount");
26
27 namespace grpc_core {
28
29 //
30 // Resolver
31 //
32
33 Resolver::Resolver(grpc_combiner* combiner,
34                    UniquePtr<ResultHandler> result_handler)
35     : InternallyRefCounted(&grpc_trace_resolver_refcount),
36       result_handler_(std::move(result_handler)),
37       combiner_(GRPC_COMBINER_REF(combiner, "resolver")) {}
38
39 Resolver::~Resolver() { GRPC_COMBINER_UNREF(combiner_, "resolver"); }
40
41 //
42 // Resolver::Result
43 //
44
45 Resolver::Result::~Result() {
46   GRPC_ERROR_UNREF(service_config_error);
47   grpc_channel_args_destroy(args);
48 }
49
50 Resolver::Result::Result(const Result& other) {
51   addresses = other.addresses;
52   service_config = other.service_config;
53   service_config_error = GRPC_ERROR_REF(other.service_config_error);
54   args = grpc_channel_args_copy(other.args);
55 }
56
57 Resolver::Result::Result(Result&& other) {
58   addresses = std::move(other.addresses);
59   service_config = std::move(other.service_config);
60   service_config_error = other.service_config_error;
61   other.service_config_error = GRPC_ERROR_NONE;
62   args = other.args;
63   other.args = nullptr;
64 }
65
66 Resolver::Result& Resolver::Result::operator=(const Result& other) {
67   addresses = other.addresses;
68   service_config = other.service_config;
69   GRPC_ERROR_UNREF(service_config_error);
70   service_config_error = GRPC_ERROR_REF(other.service_config_error);
71   grpc_channel_args_destroy(args);
72   args = grpc_channel_args_copy(other.args);
73   return *this;
74 }
75
76 Resolver::Result& Resolver::Result::operator=(Result&& other) {
77   addresses = std::move(other.addresses);
78   service_config = std::move(other.service_config);
79   GRPC_ERROR_UNREF(service_config_error);
80   service_config_error = other.service_config_error;
81   other.service_config_error = GRPC_ERROR_NONE;
82   grpc_channel_args_destroy(args);
83   args = other.args;
84   other.args = nullptr;
85   return *this;
86 }
87
88 }  // namespace grpc_core