summaryrefslogtreecommitdiffstats
path: root/ceee/ie/broker
diff options
context:
space:
mode:
authorvitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-26 04:45:36 +0000
committervitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-26 04:45:36 +0000
commit73f052f02736f324faa9e1e7dcd88093ddc87aba (patch)
tree75d6520cd62809ccb850aa93a1acd1e51867863a /ceee/ie/broker
parent79a56105bc932c3129db0b79695f36adfc77dd31 (diff)
downloadchromium_src-73f052f02736f324faa9e1e7dcd88093ddc87aba.zip
chromium_src-73f052f02736f324faa9e1e7dcd88093ddc87aba.tar.gz
chromium_src-73f052f02736f324faa9e1e7dcd88093ddc87aba.tar.bz2
Removed cached reference to BrokerRegistrar.
BUG=none TEST=none Review URL: http://codereview.chromium.org/5349004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67432 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ceee/ie/broker')
-rw-r--r--ceee/ie/broker/broker_rpc_client.cc27
-rw-r--r--ceee/ie/broker/broker_rpc_client.h5
-rw-r--r--ceee/ie/broker/broker_rpc_unittest.cc8
3 files changed, 20 insertions, 20 deletions
diff --git a/ceee/ie/broker/broker_rpc_client.cc b/ceee/ie/broker/broker_rpc_client.cc
index 54a308b..3bf360e 100644
--- a/ceee/ie/broker/broker_rpc_client.cc
+++ b/ceee/ie/broker/broker_rpc_client.cc
@@ -9,6 +9,7 @@
#include <atlbase.h>
#include "base/lock.h"
#include "base/logging.h"
+#include "base/win/scoped_comptr.h"
#include "broker_lib.h" // NOLINT
#include "broker_rpc_lib.h" // NOLINT
#include "ceee/common/com_utils.h"
@@ -57,19 +58,21 @@ void BrokerRpcClient::ReleaseContext() {
} RpcEndExcept
}
-HRESULT BrokerRpcClient::StartServer() {
- // TODO(vitalybuka@google.com): Start broker without COM after the last
- // COM interface is removed.
- CComPtr<ICeeeBrokerRegistrar> broker;
- HRESULT hr = broker.CoCreateInstance(CLSID_CeeeBroker);
- LOG_IF(ERROR, FAILED(hr)) << "Failed to create broker. " << com::LogHr(hr);
- return hr;
-}
-
-HRESULT BrokerRpcClient::Connect() {
+HRESULT BrokerRpcClient::Connect(bool start_server) {
if (is_connected())
return S_OK;
+ // Keep alive until RPC is connected.
+ base::win::ScopedComPtr<ICeeeBrokerRegistrar> broker;
+ if (start_server) {
+ // TODO(vitalybuka@google.com): Start broker without COM after the last
+ // COM interface is removed.
+ HRESULT hr = broker.CreateInstance(CLSID_CeeeBroker);
+ LOG_IF(ERROR, FAILED(hr)) << "Failed to create broker. " << com::LogHr(hr);
+ if (FAILED(hr))
+ return hr;
+ }
+
std::wstring end_point = GetRpcEndPointAddress();
std::wstring protocol = kRpcProtocol;
DCHECK(!protocol.empty());
@@ -130,7 +133,7 @@ HRESULT BrokerRpcClient::FireEvent(const char* event_name,
} RpcExcept(HandleRpcException(RpcExceptionCode())) {
LogRpcException("RPC error in FireEvent", RpcExceptionCode());
} RpcEndExcept
- return RPC_E_FAULT;
+ return RPC_E_FAULT;
}
bool BrokerRpcClient::SendUmaHistogramTimes(BSTR event_name, int sample) {
@@ -147,7 +150,7 @@ bool BrokerRpcClient::SendUmaHistogramData(BSTR event_name, int sample,
int min, int max, int bucket_count) {
RpcTryExcept {
BrokerRpcClient_SendUmaHistogramData(binding_handle_, event_name, sample,
- min, max, bucket_count);
+ min, max, bucket_count);
return true;
} RpcExcept(HandleRpcException(RpcExceptionCode())) {
LogRpcException("RPC error in SendUmaHistogramData", RpcExceptionCode());
diff --git a/ceee/ie/broker/broker_rpc_client.h b/ceee/ie/broker/broker_rpc_client.h
index fc38c0d..0f96e0e 100644
--- a/ceee/ie/broker/broker_rpc_client.h
+++ b/ceee/ie/broker/broker_rpc_client.h
@@ -17,7 +17,7 @@ class BrokerRpcClient {
virtual ~BrokerRpcClient();
// Initialize connection with server.
- virtual HRESULT Connect();
+ virtual HRESULT Connect(bool start_server);
// Relese connection with server
virtual void Disconnect();
@@ -41,9 +41,6 @@ class BrokerRpcClient {
int bucket_count);
// @}
- // Starts new CEEE broker if nessesary.
- static HRESULT StartServer();
-
private:
void LockContext();
void ReleaseContext();
diff --git a/ceee/ie/broker/broker_rpc_unittest.cc b/ceee/ie/broker/broker_rpc_unittest.cc
index dd75832..ba24a56 100644
--- a/ceee/ie/broker/broker_rpc_unittest.cc
+++ b/ceee/ie/broker/broker_rpc_unittest.cc
@@ -48,7 +48,7 @@ class BrokerRpcTest : public testing::Test {
TEST_F(BrokerRpcTest, ConnectNoServer) {
BrokerRpcClient client;
ASSERT_FALSE(client.is_connected());
- ASSERT_FALSE(SUCCEEDED(client.Connect()));
+ ASSERT_FALSE(SUCCEEDED(client.Connect(false)));
ASSERT_FALSE(client.is_connected());
}
@@ -58,7 +58,7 @@ TEST_F(BrokerRpcTest, Connect) {
ASSERT_TRUE(server.Start());
ASSERT_TRUE(server.is_started());
BrokerRpcClient client;
- ASSERT_TRUE(SUCCEEDED(client.Connect()));
+ ASSERT_TRUE(SUCCEEDED(client.Connect(false)));
ASSERT_TRUE(client.is_connected());
}
@@ -67,14 +67,14 @@ TEST_F(BrokerRpcTest, FireEvent) {
ASSERT_TRUE(server.Start());
BrokerRpcClient client;
- ASSERT_TRUE(SUCCEEDED(client.Connect()));
+ ASSERT_TRUE(SUCCEEDED(client.Connect(false)));
const char* event_name = "event_name";
const char* event_args = "event_args";
EXPECT_CALL(broker_rpc_mock_, BrokerRpcServer_FireEvent(_, StrEq(event_name),
StrEq(event_args)))
- .Times(1);
+ .Times(1);
ASSERT_TRUE(SUCCEEDED(client.FireEvent(event_name, event_args)));
}