3 * Copyright 2015 gRPC authors.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <grpc/support/port_platform.h>
21 #include "src/core/ext/filters/client_channel/resolver.h"
22 #include "src/core/lib/iomgr/combiner.h"
24 grpc_core::DebugOnlyTraceFlag grpc_trace_resolver_refcount(false,
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")) {}
39 Resolver::~Resolver() { GRPC_COMBINER_UNREF(combiner_, "resolver"); }
45 Resolver::Result::~Result() {
46 GRPC_ERROR_UNREF(service_config_error);
47 grpc_channel_args_destroy(args);
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);
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;
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);
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);
88 } // namespace grpc_core