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

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

Issue 5720004: Added refreshing of elevation policy on first run of new version for all user... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Broker RPC Client implementation. 5 // Broker RPC Client implementation.
6 6
7 #include "ceee/ie/broker/broker_rpc_client.h" 7 #include "ceee/ie/broker/broker_rpc_client.h"
8 8
9 #include <atlbase.h> 9 #include <atlbase.h>
Jói 2010/12/11 02:23:14 I think we normally put one blank line after all t
Vitaly Buka (NO REVIEWS) 2010/12/11 08:26:24 Done.
10 #include "base/lock.h" 10 #include "base/lock.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/tuple.h" 12 #include "base/tuple.h"
13 #include "base/win/scoped_comptr.h" 13 #include "base/win/scoped_comptr.h"
14 #include "broker_lib.h" // NOLINT 14 #include "broker_lib.h" // NOLINT
Jói 2010/12/11 02:23:14 our convention has been to put pathless includes l
Vitaly Buka (NO REVIEWS) 2010/12/11 08:26:24 Done.
15 #include "broker_rpc_lib.h" // NOLINT 15 #include "broker_rpc_lib.h" // NOLINT
16 #include "ceee/common/com_utils.h" 16 #include "ceee/common/com_utils.h"
17 #include "ceee/ie/broker/broker_rpc_utils.h" 17 #include "ceee/ie/broker/broker_rpc_utils.h"
18 #include "ceee/ie/common/ceee_module_util.h"
18 19
19 20
20 namespace { 21 namespace {
21 22
22 // Avoid using objects requiring unwind in functions that use __try. 23 // Avoid using objects requiring unwind in functions that use __try.
23 void LogRpcException(const char* str, unsigned int exception_code) { 24 void LogRpcException(const char* str, unsigned int exception_code) {
24 LOG(ERROR) << str << com::LogWe(exception_code); 25 LOG(ERROR) << str << com::LogWe(exception_code);
25 } 26 }
26 27
27 // Avoid using objects requiring unwind in functions that use __try. 28 // Avoid using objects requiring unwind in functions that use __try.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 109 }
109 110
110 void BrokerRpcClient::ReleaseContext() { 111 void BrokerRpcClient::ReleaseContext() {
111 RpcTryExcept { 112 RpcTryExcept {
112 BrokerRpcClient_Disconnect(binding_handle_, &context_); 113 BrokerRpcClient_Disconnect(binding_handle_, &context_);
113 } RpcExcept(HandleRpcException(RpcExceptionCode())) { 114 } RpcExcept(HandleRpcException(RpcExceptionCode())) {
114 LogRpcException("RPC error in ReleaseContext", RpcExceptionCode()); 115 LogRpcException("RPC error in ReleaseContext", RpcExceptionCode());
115 } RpcEndExcept 116 } RpcEndExcept
116 } 117 }
117 118
118 HRESULT BrokerRpcClient::StartServer(IUnknown** server) { 119 HRESULT BrokerRpcClient::StartServer(ICeeeBrokerRegistrar** server) {
119 base::win::ScopedComPtr<IUnknown> broker; 120 return StartCeeeBroker(server);
120 // TODO(vitalybuka@google.com): Start broker without COM after the last
121 // COM interface is removed.
122 HRESULT hr = broker.CreateInstance(CLSID_CeeeBroker);
123 LOG_IF(ERROR, FAILED(hr)) << "Failed to create broker. " << com::LogHr(hr);
124 if (FAILED(hr))
125 return hr;
126 *server = broker.Detach();
127 return S_OK;
128 } 121 }
129 122
130 HRESULT BrokerRpcClient::Connect(bool start_server) { 123 HRESULT BrokerRpcClient::Connect(bool start_server) {
131 if (is_connected()) 124 if (is_connected())
132 return S_OK; 125 return S_OK;
133 126
134 // Keep alive until RPC is connected. 127 // Keep alive until RPC is connected.
135 base::win::ScopedComPtr<IUnknown> broker; 128 base::win::ScopedComPtr<ICeeeBrokerRegistrar> broker;
136 if (start_server) { 129 if (start_server) {
137 HRESULT hr = StartServer(broker.Receive()); 130 HRESULT hr = StartServer(broker.Receive());
138 if (FAILED(hr)) 131 if (FAILED(hr))
139 return hr; 132 return hr;
140 } 133 }
141 134
142 if (SUCCEEDED(BindRpc(GetRpcEndpointAddress(), &binding_handle_))) 135 if (SUCCEEDED(BindRpc(GetRpcEndpointAddress(), &binding_handle_)))
143 LockContext(); 136 LockContext();
144 137
145 if (!is_connected()) { 138 if (!is_connected()) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 HRESULT BrokerRpcClient::SendUmaHistogramData(const char* name, 197 HRESULT BrokerRpcClient::SendUmaHistogramData(const char* name,
205 int sample, 198 int sample,
206 int min, 199 int min,
207 int max, 200 int max,
208 int bucket_count) { 201 int bucket_count) {
209 return RunRpc(allow_restarts_, 202 return RunRpc(allow_restarts_,
210 &BrokerRpcClient_SendUmaHistogramData, 203 &BrokerRpcClient_SendUmaHistogramData,
211 MakeRefTuple(binding_handle_, name, sample, min, max, 204 MakeRefTuple(binding_handle_, name, sample, min, max,
212 bucket_count)); 205 bucket_count));
213 } 206 }
207
208 HRESULT StartCeeeBroker(ICeeeBrokerRegistrar** broker) {
209 ceee_module_util::RefreshElevationPolicyIfNeeded();
210 base::win::ScopedComPtr<ICeeeBrokerRegistrar> broker_tmp;
211 // TODO(vitalybuka@google.com): Start broker without COM after the last
212 // COM interface is removed.
213 HRESULT hr = broker_tmp.CreateInstance(CLSID_CeeeBroker);
214 LOG_IF(ERROR, FAILED(hr)) << "Failed to create broker. " << com::LogHr(hr);
Jói 2010/12/11 02:23:14 nit: suggest moving inside the if (FAILED(hr)) con
Vitaly Buka (NO REVIEWS) 2010/12/11 08:26:24 Done.
215 if (FAILED(hr))
216 return hr;
217 *broker = broker_tmp.Detach();
218 return S_OK;
219 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698