1 : // Copyright 2012 Google Inc. All Rights Reserved.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 :
15 : // This file implements the RPC stubs which bind the CallTraceService RPC
16 : // handlers to a call trace Service instance.
17 :
18 : #include "syzygy/trace/service/service_rpc_impl.h"
19 :
20 : #include "syzygy/trace/service/service.h"
21 :
22 : using trace::service::RpcServiceInstanceManager;
23 : using trace::service::Service;
24 :
25 : // The instance to which the RPC callbacks are bound.
26 : Service* RpcServiceInstanceManager::instance_ = NULL;
27 :
28 : // RPC entrypoint for CallTraceService::CreateSession().
29 : boolean CallTraceService_CreateSession(
30 : /* [in] */ handle_t binding,
31 : /* [out] */ SessionHandle* session_handle,
32 : /* [out] */ CallTraceBuffer* call_trace_buffer,
33 E : /* [out] */ unsigned long* flags) {
34 E : Service* instance = RpcServiceInstanceManager::GetInstance();
35 : return instance->CreateSession(binding,
36 : session_handle,
37 : call_trace_buffer,
38 E : flags);
39 E : }
40 :
41 : // RPC entrypoint for CallTraceService:AllocateBuffer().
42 : boolean CallTraceService_AllocateBuffer(
43 : /* [in] */ SessionHandle session_handle,
44 E : /* [out] */ CallTraceBuffer* call_trace_buffer) {
45 E : Service* instance = RpcServiceInstanceManager::GetInstance();
46 E : return instance->AllocateBuffer(session_handle, call_trace_buffer);
47 E : }
48 :
49 : // RPC entrypoint for CallTraceService:AllocateLargeBuffer().
50 : boolean CallTraceService_AllocateLargeBuffer(
51 : /* [in] */ SessionHandle session_handle,
52 : /* [in] */ unsigned long minimum_size,
53 E : /* [out] */ CallTraceBuffer* call_trace_buffer) {
54 E : Service* instance = RpcServiceInstanceManager::GetInstance();
55 : return instance->AllocateLargeBuffer(
56 E : session_handle, minimum_size, call_trace_buffer);
57 E : }
58 :
59 : // RPC entrypoint for CallTraceService::ExchangeBuffer().
60 : boolean CallTraceService_ExchangeBuffer(
61 : /* [in] */ SessionHandle session_handle,
62 E : /* [out][in] */ CallTraceBuffer* call_trace_buffer) {
63 E : Service* instance = RpcServiceInstanceManager::GetInstance();
64 : return instance->CommitAndExchangeBuffer(session_handle,
65 : call_trace_buffer,
66 E : Service::PERFORM_EXCHANGE);
67 E : }
68 :
69 : // RPC entrypoint for CallTraceService::ReturnBuffer().
70 : boolean CallTraceService_ReturnBuffer(
71 : /* [in] */ SessionHandle session_handle,
72 E : /* [out][in] */ CallTraceBuffer* call_trace_buffer) {
73 E : Service* instance = RpcServiceInstanceManager::GetInstance();
74 : return instance->CommitAndExchangeBuffer(session_handle,
75 : call_trace_buffer,
76 E : Service::DO_NOT_PERFORM_EXCHANGE);
77 E : }
78 :
79 : // RPC entrypoint for CallTraceService::CloseSession().
80 : boolean CallTraceService_CloseSession(
81 E : /* [out][in] */ SessionHandle* session_handle) {
82 E : Service* instance = RpcServiceInstanceManager::GetInstance();
83 E : ignore_result(instance->CloseSession(session_handle));
84 E : return true;
85 E : }
86 :
87 : // RPC entrypoint for CallTraceControl::Stop().
88 E : boolean CallTraceService_Stop(/* [in] */ handle_t /* binding */) {
89 E : Service* instance = RpcServiceInstanceManager::GetInstance();
90 E : return instance->RequestShutdown();
91 E : }
92 :
93 : // This callback is invoked if the RPC mechanism detects that a client
94 : // has ceased to exist, but the service still has resources allocated
95 : // on the client's behalf.
96 i : void __RPC_USER SessionHandle_rundown(SessionHandle session_handle) {
97 i : Service* instance = RpcServiceInstanceManager::GetInstance();
98 i : ignore_result(instance->CloseSession(&session_handle));
99 i : }
|