[Chromoting] Replace some bare pointers with scoped_ptrs, and improve naming.

This is a follow-up to codereview.chromium.org/10409017

BUG=126491

Review URL: https://chromiumcodereview.appspot.com/10399127

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138331 0039d316-1c4b-4281-b951-d872f2087c98
parent f8a8475d
...@@ -45,7 +45,7 @@ void LogToServer::LogSessionStateChange(bool connected) { ...@@ -45,7 +45,7 @@ void LogToServer::LogSessionStateChange(bool connected) {
DCHECK(CalledOnValidThread()); DCHECK(CalledOnValidThread());
scoped_ptr<ServerLogEntry> entry( scoped_ptr<ServerLogEntry> entry(
ServerLogEntry::MakeSessionStateChange(connected)); ServerLogEntry::MakeForSessionStateChange(connected));
entry->AddHostFields(); entry->AddHostFields();
entry->AddModeField(mode_); entry->AddModeField(mode_);
......
...@@ -63,20 +63,21 @@ scoped_ptr<buzz::XmlElement> ServerLogEntry::MakeStanza() { ...@@ -63,20 +63,21 @@ scoped_ptr<buzz::XmlElement> ServerLogEntry::MakeStanza() {
} }
// static // static
ServerLogEntry* ServerLogEntry::MakeSessionStateChange(bool connected) { scoped_ptr<ServerLogEntry> ServerLogEntry::MakeForSessionStateChange(
ServerLogEntry* entry = new ServerLogEntry(); bool connected) {
scoped_ptr<ServerLogEntry> entry(new ServerLogEntry());
entry->Set(kKeyRole, kValueRoleHost); entry->Set(kKeyRole, kValueRoleHost);
entry->Set(kKeyEventName, kValueEventNameSessionState); entry->Set(kKeyEventName, kValueEventNameSessionState);
entry->Set(kKeySessionState, GetValueSessionState(connected)); entry->Set(kKeySessionState, GetValueSessionState(connected));
return entry; return entry.Pass();
} }
// static // static
ServerLogEntry* ServerLogEntry::MakeForHeartbeat() { scoped_ptr<ServerLogEntry> ServerLogEntry::MakeForHeartbeat() {
ServerLogEntry* entry = new ServerLogEntry(); scoped_ptr<ServerLogEntry> entry(new ServerLogEntry());
entry->Set(kKeyRole, kValueRoleHost); entry->Set(kKeyRole, kValueRoleHost);
entry->Set(kKeyEventName, kValueEventNameHeartbeat); entry->Set(kKeyEventName, kValueEventNameHeartbeat);
return entry; return entry.Pass();
} }
void ServerLogEntry::AddHostFields() { void ServerLogEntry::AddHostFields() {
......
...@@ -32,10 +32,10 @@ class ServerLogEntry { ...@@ -32,10 +32,10 @@ class ServerLogEntry {
// Constructs a log entry for a session state change. // Constructs a log entry for a session state change.
// Currently this is either connection or disconnection. // Currently this is either connection or disconnection.
static ServerLogEntry* MakeSessionStateChange(bool connection); static scoped_ptr<ServerLogEntry> MakeForSessionStateChange(bool connection);
// Constructs a log entry for a heartbeat. // Constructs a log entry for a heartbeat.
static ServerLogEntry* MakeForHeartbeat(); static scoped_ptr<ServerLogEntry> MakeForHeartbeat();
~ServerLogEntry(); ~ServerLogEntry();
......
...@@ -60,9 +60,9 @@ class ServerLogEntryTest : public testing::Test { ...@@ -60,9 +60,9 @@ class ServerLogEntryTest : public testing::Test {
} }
}; };
TEST_F(ServerLogEntryTest, MakeSessionStateChange) { TEST_F(ServerLogEntryTest, MakeForSessionStateChange) {
scoped_ptr<ServerLogEntry> entry( scoped_ptr<ServerLogEntry> entry(
ServerLogEntry::MakeSessionStateChange(true)); ServerLogEntry::MakeForSessionStateChange(true));
scoped_ptr<XmlElement> stanza = entry->ToStanza(); scoped_ptr<XmlElement> stanza = entry->ToStanza();
std::string error; std::string error;
std::map<std::string, std::string> key_value_pairs; std::map<std::string, std::string> key_value_pairs;
...@@ -74,7 +74,7 @@ TEST_F(ServerLogEntryTest, MakeSessionStateChange) { ...@@ -74,7 +74,7 @@ TEST_F(ServerLogEntryTest, MakeSessionStateChange) {
<< error; << error;
} }
TEST_F(ServerLogEntryTest, MakeHeartbeat) { TEST_F(ServerLogEntryTest, MakeForHeartbeat) {
scoped_ptr<ServerLogEntry> entry(ServerLogEntry::MakeForHeartbeat()); scoped_ptr<ServerLogEntry> entry(ServerLogEntry::MakeForHeartbeat());
scoped_ptr<XmlElement> stanza = entry->ToStanza(); scoped_ptr<XmlElement> stanza = entry->ToStanza();
std::string error; std::string error;
...@@ -88,7 +88,7 @@ TEST_F(ServerLogEntryTest, MakeHeartbeat) { ...@@ -88,7 +88,7 @@ TEST_F(ServerLogEntryTest, MakeHeartbeat) {
TEST_F(ServerLogEntryTest, AddHostFields) { TEST_F(ServerLogEntryTest, AddHostFields) {
scoped_ptr<ServerLogEntry> entry( scoped_ptr<ServerLogEntry> entry(
ServerLogEntry::MakeSessionStateChange(true)); ServerLogEntry::MakeForSessionStateChange(true));
entry->AddHostFields(); entry->AddHostFields();
scoped_ptr<XmlElement> stanza = entry->ToStanza(); scoped_ptr<XmlElement> stanza = entry->ToStanza();
std::string error; std::string error;
...@@ -116,7 +116,7 @@ TEST_F(ServerLogEntryTest, AddHostFields) { ...@@ -116,7 +116,7 @@ TEST_F(ServerLogEntryTest, AddHostFields) {
TEST_F(ServerLogEntryTest, AddModeField1) { TEST_F(ServerLogEntryTest, AddModeField1) {
scoped_ptr<ServerLogEntry> entry( scoped_ptr<ServerLogEntry> entry(
ServerLogEntry::MakeSessionStateChange(true)); ServerLogEntry::MakeForSessionStateChange(true));
entry->AddModeField(ServerLogEntry::IT2ME); entry->AddModeField(ServerLogEntry::IT2ME);
scoped_ptr<XmlElement> stanza = entry->ToStanza(); scoped_ptr<XmlElement> stanza = entry->ToStanza();
std::string error; std::string error;
...@@ -132,7 +132,7 @@ TEST_F(ServerLogEntryTest, AddModeField1) { ...@@ -132,7 +132,7 @@ TEST_F(ServerLogEntryTest, AddModeField1) {
TEST_F(ServerLogEntryTest, AddModeField2) { TEST_F(ServerLogEntryTest, AddModeField2) {
scoped_ptr<ServerLogEntry> entry( scoped_ptr<ServerLogEntry> entry(
ServerLogEntry::MakeSessionStateChange(true)); ServerLogEntry::MakeForSessionStateChange(true));
entry->AddModeField(ServerLogEntry::ME2ME); entry->AddModeField(ServerLogEntry::ME2ME);
scoped_ptr<XmlElement> stanza = entry->ToStanza(); scoped_ptr<XmlElement> stanza = entry->ToStanza();
std::string error; std::string error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment