blob: 9e02ac5a3c5c99abd3d186421d6b0899e3ce3207 [file] [log] [blame]
yangga4b6f5d2014-12-17 15:53:12 -08001/*
2 *
3 * Copyright 2014, Google Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
Craig Tillerc4165772015-02-11 10:51:04 -080034#include <grpc++/server_context.h>
Craig Tiller01567522015-02-11 21:08:49 -080035#include <grpc++/impl/call.h>
Craig Tiller854a30c2015-02-11 11:44:10 -080036#include <grpc/grpc.h>
37#include "src/cpp/util/time.h"
yangga4b6f5d2014-12-17 15:53:12 -080038
Craig Tiller854a30c2015-02-11 11:44:10 -080039namespace grpc {
40
Craig Tiller9dcb0f82015-02-11 15:36:31 -080041ServerContext::ServerContext(gpr_timespec deadline, grpc_metadata *metadata,
42 size_t metadata_count)
43 : deadline_(Timespec2Timepoint(deadline)) {
Craig Tiller854a30c2015-02-11 11:44:10 -080044 for (size_t i = 0; i < metadata_count; i++) {
Craig Tiller9dcb0f82015-02-11 15:36:31 -080045 client_metadata_.insert(std::make_pair(
46 grpc::string(metadata[i].key),
47 grpc::string(metadata[i].value,
48 metadata[i].value + metadata[i].value_length)));
Craig Tiller854a30c2015-02-11 11:44:10 -080049 }
50}
51
Craig Tiller3d6ceb62015-02-12 14:33:54 -080052ServerContext::~ServerContext() {
53 if (call_) {
54 grpc_call_destroy(call_);
55 }
56}
57
Craig Tiller854a30c2015-02-11 11:44:10 -080058} // namespace grpc