Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Side by Side Diff: ceee/ie/broker/broker_rpc_server.cc

Issue 4508002: COM replaced with RPC for firing events in broker. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium 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 #include "ceee/ie/broker/broker_rpc_server.h"
6
7 #include "base/logging.h"
8 #include "base/win_util.h"
9 #include "broker_rpc_lib.h"
10 #include "ceee/ie/broker/broker_module_util.h"
11 #include "ceee/ie/broker/broker_rpc_utils.h"
12 #include "ceee/ie/broker/chrome_postman.h"
13
14
15 BrokerRpcServer::BrokerRpcServer() : is_started_(false) {
16 }
17
18 BrokerRpcServer::~BrokerRpcServer() {
19 Stop();
20 }
21
22 bool BrokerRpcServer::Start() {
23 if (is_started())
24 return true;
25
26 std::wstring end_point = GetRpcEndPointAddress();
27 std::wstring protocol = kRpcProtocol;
28 DCHECK(!protocol.empty());
29 DCHECK(!end_point.empty());
30 if (protocol.empty() || end_point.empty())
31 return false;
32
33 LOG(INFO) << "RPC server is starting. Endpoint: " << end_point;
34 RPC_STATUS status = RpcServerUseProtseqEp(
35 reinterpret_cast<RPC_WSTR>(&protocol[0]),
36 RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
37 reinterpret_cast<RPC_WSTR>(&end_point[0]),
38 NULL);
39 DCHECK(RPC_S_OK == status);
40
41 if (RPC_S_OK == status) {
42 status = RpcServerRegisterIfEx(BrokerRpcServer_Broker_v1_1_s_ifspec, NULL,
43 NULL, 0, RPC_C_LISTEN_MAX_CALLS_DEFAULT, NULL);
44 DCHECK(RPC_S_OK == status);
45
46 if (RPC_S_OK == status) {
47 status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, TRUE);
48 DCHECK(RPC_S_OK == status);
49
50 if (RPC_S_OK == status) {
51 LOG(INFO) << "RPC server is started. Endpoint: " << end_point;
52 is_started_ = true;
53 }
54 }
55 }
56
57 return is_started();
58 }
59
60 bool BrokerRpcServer::Stop() {
61 if (!is_started())
62 return true;
63 is_started_ = false;
64 RPC_STATUS status = RpcServerUnregisterIf(
65 BrokerRpcServer_Broker_v1_1_s_ifspec, NULL, FALSE);
66 DCHECK(RPC_S_OK == status);
67 return RPC_S_OK == status;
68 }
69
70 void BrokerRpcServer_FireEvent(
71 handle_t binding_handle,
72 BSTR event_name,
73 BSTR event_args) {
74 DCHECK(ChromePostman::GetInstance());
75 if (ChromePostman::GetInstance())
76 ChromePostman::GetInstance()->FireEvent(event_name, event_args);
77 }
78
79 BrokerContextHandle BrokerRpcServer_Connect(
80 handle_t binding_handle) {
81 static long current_context = 0;
82 ceee_module_util::LockModule();
83 return reinterpret_cast<void*>(InterlockedIncrement(&current_context));
84 }
85
86 void BrokerRpcServer_Disconnect(
87 handle_t binding_handle,
88 BrokerContextHandle* context) {
89 DCHECK(context != NULL);
90 if (context) {
91 *context = NULL;
92 }
93 ceee_module_util::UnlockModule();
94 }
95
96 void __RPC_USER BrokerContextHandle_rundown(BrokerContextHandle context) {
97 DCHECK(context != NULL);
98 ceee_module_util::UnlockModule();
99 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698