summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-20 20:31:44 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-20 20:31:44 +0000
commit3361e1f24a5dd45ae86478af20c617d0b1ce40e0 (patch)
tree70079ed87a90f8f2322de722e6073ba192931196 /remoting
parentbd1a64b72240734d1061b7edd95ec9f268792c49 (diff)
downloadchromium_src-3361e1f24a5dd45ae86478af20c617d0b1ce40e0.zip
chromium_src-3361e1f24a5dd45ae86478af20c617d0b1ce40e0.tar.gz
chromium_src-3361e1f24a5dd45ae86478af20c617d0b1ce40e0.tar.bz2
Use scoped_ptr<> to pass ownership in more places.
Review URL: http://codereview.chromium.org/9720019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127767 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/base/codec_test.cc8
-rw-r--r--remoting/base/encoder.h6
-rw-r--r--remoting/base/encoder_row_based.cc18
-rw-r--r--remoting/base/encoder_vp8.cc30
-rw-r--r--remoting/base/encoder_vp8_unittest.cc5
-rw-r--r--remoting/host/chromoting_host.cc6
-rw-r--r--remoting/host/chromoting_host_unittest.cc16
-rw-r--r--remoting/host/client_session.cc6
-rw-r--r--remoting/host/client_session.h4
-rw-r--r--remoting/host/client_session_unittest.cc5
-rw-r--r--remoting/host/continue_window.h4
-rw-r--r--remoting/host/continue_window_linux.cc6
-rw-r--r--remoting/host/continue_window_mac.mm6
-rw-r--r--remoting/host/continue_window_win.cc6
-rw-r--r--remoting/host/disconnect_window.h6
-rw-r--r--remoting/host/disconnect_window_linux.cc6
-rw-r--r--remoting/host/disconnect_window_mac.mm6
-rw-r--r--remoting/host/disconnect_window_win.cc6
-rw-r--r--remoting/host/event_executor.h1
-rw-r--r--remoting/host/heartbeat_sender.h6
-rw-r--r--remoting/host/host_mock_objects.cc12
-rw-r--r--remoting/host/it2me_host_user_interface.cc13
-rw-r--r--remoting/host/it2me_host_user_interface.h9
-rw-r--r--remoting/host/local_input_monitor.h6
-rw-r--r--remoting/host/local_input_monitor_linux.cc25
-rw-r--r--remoting/host/local_input_monitor_mac.mm16
-rw-r--r--remoting/host/local_input_monitor_win.cc28
-rw-r--r--remoting/host/log_to_server.cc2
-rw-r--r--remoting/host/register_support_host_request.h1
-rw-r--r--remoting/host/screen_recorder.cc54
-rw-r--r--remoting/host/screen_recorder.h14
-rw-r--r--remoting/host/screen_recorder_unittest.cc4
-rw-r--r--remoting/host/server_log_entry.cc8
-rw-r--r--remoting/host/server_log_entry.h5
-rw-r--r--remoting/host/server_log_entry_unittest.cc8
35 files changed, 178 insertions, 184 deletions
diff --git a/remoting/base/codec_test.cc b/remoting/base/codec_test.cc
index aa761d8..5fd58ed 100644
--- a/remoting/base/codec_test.cc
+++ b/remoting/base/codec_test.cc
@@ -211,16 +211,14 @@ class EncoderTester {
EXPECT_GT(data_available_, 0);
}
- void DataAvailable(VideoPacket *packet) {
+ void DataAvailable(scoped_ptr<VideoPacket> packet) {
++data_available_;
- message_tester_->ReceivedPacket(packet);
+ message_tester_->ReceivedPacket(packet.get());
// Send the message to the DecoderTester.
if (decoder_tester_) {
- decoder_tester_->ReceivedPacket(packet);
+ decoder_tester_->ReceivedPacket(packet.get());
}
-
- delete packet;
}
void AddRects(const SkIRect* rects, int count) {
diff --git a/remoting/base/encoder.h b/remoting/base/encoder.h
index d1f226a..ae6fadc 100644
--- a/remoting/base/encoder.h
+++ b/remoting/base/encoder.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -27,9 +27,7 @@ class Encoder {
// DataAvailableCallback is called as blocks of data are made available
// from the encoder. Data made available by the encoder is in the form
// of HostMessage to reduce the amount of memory copies.
- // The callback takes ownership of the HostMessage and is responsible for
- // deleting it.
- typedef base::Callback<void(VideoPacket*)> DataAvailableCallback;
+ typedef base::Callback<void(scoped_ptr<VideoPacket>)> DataAvailableCallback;
virtual ~Encoder() {}
diff --git a/remoting/base/encoder_row_based.cc b/remoting/base/encoder_row_based.cc
index 332cde3..c84b38a 100644
--- a/remoting/base/encoder_row_based.cc
+++ b/remoting/base/encoder_row_based.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -86,21 +86,21 @@ void EncoderRowBased::EncodeRect(const SkIRect& rect, bool last) {
compressor_->Reset();
- VideoPacket* packet = new VideoPacket();
- PrepareUpdateStart(rect, packet);
+ scoped_ptr<VideoPacket> packet(new VideoPacket());
+ PrepareUpdateStart(rect, packet.get());
const uint8* in = capture_data_->data_planes().data[0] +
rect.fTop * strides + rect.fLeft * bytes_per_pixel;
// TODO(hclam): Fill in the sequence number.
- uint8* out = GetOutputBuffer(packet, packet_size_);
+ uint8* out = GetOutputBuffer(packet.get(), packet_size_);
int filled = 0;
int row_pos = 0; // Position in the current row in bytes.
int row_y = 0; // Current row.
bool compress_again = true;
while (compress_again) {
// Prepare a message for sending out.
- if (!packet) {
- packet = new VideoPacket();
- out = GetOutputBuffer(packet, packet_size_);
+ if (!packet.get()) {
+ packet.reset(new VideoPacket());
+ out = GetOutputBuffer(packet.get(), packet_size_);
filled = 0;
}
@@ -132,8 +132,7 @@ void EncoderRowBased::EncodeRect(const SkIRect& rect, bool last) {
// If we have filled the message or we have reached the end of stream.
if (filled == packet_size_ || !compress_again) {
packet->mutable_data()->resize(filled);
- callback_.Run(packet);
- packet = NULL;
+ callback_.Run(packet.Pass());
}
// Reached the end of input row and we're not at the last row.
@@ -169,5 +168,4 @@ uint8* EncoderRowBased::GetOutputBuffer(VideoPacket* packet, size_t size) {
packet->mutable_data()->data()));
}
-
} // namespace remoting
diff --git a/remoting/base/encoder_vp8.cc b/remoting/base/encoder_vp8.cc
index 6317821..ed126d1 100644
--- a/remoting/base/encoder_vp8.cc
+++ b/remoting/base/encoder_vp8.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -259,41 +259,41 @@ void EncoderVp8::Encode(scoped_refptr<CaptureData> capture_data,
// TODO(hclam): Make sure we get exactly one frame from the packet.
// TODO(hclam): We should provide the output buffer to avoid one copy.
- VideoPacket* message = new VideoPacket();
+ scoped_ptr<VideoPacket> packet(new VideoPacket());
while (!got_data) {
- const vpx_codec_cx_pkt_t* packet = vpx_codec_get_cx_data(codec_.get(),
- &iter);
- if (!packet)
+ const vpx_codec_cx_pkt_t* vpx_packet = vpx_codec_get_cx_data(codec_.get(),
+ &iter);
+ if (!vpx_packet)
continue;
- switch (packet->kind) {
+ switch (vpx_packet->kind) {
case VPX_CODEC_CX_FRAME_PKT:
got_data = true;
// TODO(sergeyu): Split each frame into multiple partitions.
- message->set_data(packet->data.frame.buf, packet->data.frame.sz);
+ packet->set_data(vpx_packet->data.frame.buf, vpx_packet->data.frame.sz);
break;
default:
break;
}
}
- message->mutable_format()->set_encoding(VideoPacketFormat::ENCODING_VP8);
- message->set_flags(VideoPacket::FIRST_PACKET | VideoPacket::LAST_PACKET |
+ packet->mutable_format()->set_encoding(VideoPacketFormat::ENCODING_VP8);
+ packet->set_flags(VideoPacket::FIRST_PACKET | VideoPacket::LAST_PACKET |
VideoPacket::LAST_PARTITION);
- message->mutable_format()->set_screen_width(capture_data->size().width());
- message->mutable_format()->set_screen_height(capture_data->size().height());
- message->set_capture_time_ms(capture_data->capture_time_ms());
- message->set_client_sequence_number(capture_data->client_sequence_number());
+ packet->mutable_format()->set_screen_width(capture_data->size().width());
+ packet->mutable_format()->set_screen_height(capture_data->size().height());
+ packet->set_capture_time_ms(capture_data->capture_time_ms());
+ packet->set_client_sequence_number(capture_data->client_sequence_number());
for (size_t i = 0; i < updated_rects.size(); ++i) {
- Rect* rect = message->add_dirty_rects();
+ Rect* rect = packet->add_dirty_rects();
rect->set_x(updated_rects[i].fLeft);
rect->set_y(updated_rects[i].fTop);
rect->set_width(updated_rects[i].width());
rect->set_height(updated_rects[i].height());
}
- data_available_callback.Run(message);
+ data_available_callback.Run(packet.Pass());
}
} // namespace remoting
diff --git a/remoting/base/encoder_vp8_unittest.cc b/remoting/base/encoder_vp8_unittest.cc
index 94be428..dd8c3c6 100644
--- a/remoting/base/encoder_vp8_unittest.cc
+++ b/remoting/base/encoder_vp8_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -29,8 +29,7 @@ TEST(EncoderVp8Test, TestEncoder) {
class EncoderCallback {
public:
- void DataAvailable(VideoPacket *packet) {
- delete packet;
+ void DataAvailable(scoped_ptr<VideoPacket> packet) {
}
};
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc
index ab3478a..2687127 100644
--- a/remoting/host/chromoting_host.cc
+++ b/remoting/host/chromoting_host.cc
@@ -261,10 +261,10 @@ void ChromotingHost::OnIncomingSession(
LOG(INFO) << "Client connected: " << session->jid();
// Create a client object.
- protocol::ConnectionToClient* connection =
- new protocol::ConnectionToClient(session);
+ scoped_ptr<protocol::ConnectionToClient> connection(
+ new protocol::ConnectionToClient(session));
ClientSession* client = new ClientSession(
- this, connection, desktop_environment_->event_executor(),
+ this, connection.Pass(), desktop_environment_->event_executor(),
desktop_environment_->capturer());
clients_.push_back(client);
}
diff --git a/remoting/host/chromoting_host_unittest.cc b/remoting/host/chromoting_host_unittest.cc
index a797e4b..2ff5b03 100644
--- a/remoting/host/chromoting_host_unittest.cc
+++ b/remoting/host/chromoting_host_unittest.cc
@@ -104,8 +104,10 @@ class ChromotingHostTest : public testing::Test {
local_input_monitor_ = new MockLocalInputMonitor();
it2me_host_user_interface_.reset(new It2MeHostUserInterface(host_,
&context_));
- it2me_host_user_interface_->InitFrom(disconnect_window_, continue_window_,
- local_input_monitor_);
+ it2me_host_user_interface_->InitFrom(
+ scoped_ptr<DisconnectWindow>(disconnect_window_),
+ scoped_ptr<ContinueWindow>(continue_window_),
+ scoped_ptr<LocalInputMonitor>(local_input_monitor_));
session_ = new MockSession();
session2_ = new MockSession();
@@ -178,10 +180,12 @@ class ChromotingHostTest : public testing::Test {
// Helper method to pretend a client is connected to ChromotingHost.
void SimulateClientConnection(int connection_index, bool authenticate) {
- protocol::ConnectionToClient* connection = (connection_index == 0) ?
- owned_connection_.release() : owned_connection2_.release();
+ scoped_ptr<protocol::ConnectionToClient> connection =
+ ((connection_index == 0) ? owned_connection_ : owned_connection2_).
+ PassAs<protocol::ConnectionToClient>();
+ protocol::ConnectionToClient* connection_ptr = connection.get();
ClientSession* client = new ClientSession(
- host_.get(), connection, event_executor_,
+ host_.get(), connection.Pass(), event_executor_,
desktop_environment_->capturer());
connection->set_host_stub(client);
@@ -191,7 +195,7 @@ class ChromotingHostTest : public testing::Test {
if (authenticate) {
context_.network_message_loop()->PostTask(
FROM_HERE, base::Bind(&ClientSession::OnConnectionOpened,
- base::Unretained(client), connection));
+ base::Unretained(client), connection_ptr));
}
if (connection_index == 0) {
diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc
index 81abc71..8844ce8 100644
--- a/remoting/host/client_session.cc
+++ b/remoting/host/client_session.cc
@@ -27,12 +27,12 @@ using protocol::MouseEvent;
ClientSession::ClientSession(
EventHandler* event_handler,
- protocol::ConnectionToClient* connection,
+ scoped_ptr<protocol::ConnectionToClient> connection,
protocol::HostEventStub* host_event_stub,
Capturer* capturer)
: event_handler_(event_handler),
- connection_(connection),
- client_jid_(connection->session()->jid()),
+ connection_(connection.Pass()),
+ client_jid_(connection_->session()->jid()),
host_event_stub_(host_event_stub),
capturer_(capturer),
authenticated_(false),
diff --git a/remoting/host/client_session.h b/remoting/host/client_session.h
index 6103c08..e3a4de1 100644
--- a/remoting/host/client_session.h
+++ b/remoting/host/client_session.h
@@ -57,10 +57,8 @@ class ClientSession : public protocol::HostEventStub,
const net::IPEndPoint& local_end_point) = 0;
};
- // Takes ownership of |connection|. Does not take ownership of
- // |event_handler|, |host_event_stub|, or |capturer|.
ClientSession(EventHandler* event_handler,
- protocol::ConnectionToClient* connection,
+ scoped_ptr<protocol::ConnectionToClient> connection,
protocol::HostEventStub* host_event_stub,
Capturer* capturer);
virtual ~ClientSession();
diff --git a/remoting/host/client_session_unittest.cc b/remoting/host/client_session_unittest.cc
index 38a9171..5c1a4f8 100644
--- a/remoting/host/client_session_unittest.cc
+++ b/remoting/host/client_session_unittest.cc
@@ -38,9 +38,10 @@ class ClientSessionTest : public testing::Test {
EXPECT_CALL(*session, jid()).WillRepeatedly(ReturnRef(client_jid_));
EXPECT_CALL(*session, SetStateChangeCallback(_));
+ scoped_ptr<protocol::ConnectionToClient> connection(
+ new protocol::ConnectionToClient(session));
client_session_.reset(new ClientSession(
- &session_event_handler_,
- new protocol::ConnectionToClient(session),
+ &session_event_handler_, connection.Pass(),
&host_event_stub_, &capturer_));
}
diff --git a/remoting/host/continue_window.h b/remoting/host/continue_window.h
index 1840664..384c76d 100644
--- a/remoting/host/continue_window.h
+++ b/remoting/host/continue_window.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -29,7 +29,7 @@ class ContinueWindow {
// Hide the continuation window if it is visible.
virtual void Hide() = 0;
- static ContinueWindow* Create();
+ static scoped_ptr<ContinueWindow> Create();
};
}
diff --git a/remoting/host/continue_window_linux.cc b/remoting/host/continue_window_linux.cc
index b84e49b..d166710 100644
--- a/remoting/host/continue_window_linux.cc
+++ b/remoting/host/continue_window_linux.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -102,8 +102,8 @@ void ContinueWindowLinux::OnResponse(GtkWidget* dialog, int response_id) {
Hide();
}
-ContinueWindow* ContinueWindow::Create() {
- return new ContinueWindowLinux();
+scoped_ptr<ContinueWindow> ContinueWindow::Create() {
+ return scoped_ptr<ContinueWindow>(new ContinueWindowLinux());
}
} // namespace remoting
diff --git a/remoting/host/continue_window_mac.mm b/remoting/host/continue_window_mac.mm
index f5661846..c42cf91 100644
--- a/remoting/host/continue_window_mac.mm
+++ b/remoting/host/continue_window_mac.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -67,8 +67,8 @@ void ContinueWindowMac::Hide() {
[controller_ hide];
}
-ContinueWindow* ContinueWindow::Create() {
- return new ContinueWindowMac();
+scoped_ptr<ContinueWindow> ContinueWindow::Create() {
+ return scoped_ptr<ContinueWindow>(new ContinueWindowMac());
}
} // namespace remoting
diff --git a/remoting/host/continue_window_win.cc b/remoting/host/continue_window_win.cc
index 190cc42..c62289b 100644
--- a/remoting/host/continue_window_win.cc
+++ b/remoting/host/continue_window_win.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -148,8 +148,8 @@ void ContinueWindowWin::SetStrings(const UiStrings& strings) {
SetWindowText(hwndCancel, strings.stop_sharing_button_text.c_str());
}
-ContinueWindow* ContinueWindow::Create() {
- return new ContinueWindowWin();
+scoped_ptr<ContinueWindow> ContinueWindow::Create() {
+ return scoped_ptr<ContinueWindow>(new ContinueWindowWin());
}
} // namespace remoting
diff --git a/remoting/host/disconnect_window.h b/remoting/host/disconnect_window.h
index d7e6aee..e5345ed 100644
--- a/remoting/host/disconnect_window.h
+++ b/remoting/host/disconnect_window.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,6 +7,8 @@
#include <string>
+#include "base/memory/scoped_ptr.h"
+
namespace remoting {
class ChromotingHost;
@@ -26,7 +28,7 @@ class DisconnectWindow {
// Hide the disconnect window.
virtual void Hide() = 0;
- static DisconnectWindow* Create();
+ static scoped_ptr<DisconnectWindow> Create();
};
}
diff --git a/remoting/host/disconnect_window_linux.cc b/remoting/host/disconnect_window_linux.cc
index ba4693d..5a1f0aa 100644
--- a/remoting/host/disconnect_window_linux.cc
+++ b/remoting/host/disconnect_window_linux.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -275,8 +275,8 @@ gboolean DisconnectWindowLinux::OnButtonPress(GtkWidget* widget,
return FALSE;
}
-DisconnectWindow* DisconnectWindow::Create() {
- return new DisconnectWindowLinux;
+scoped_ptr<DisconnectWindow> DisconnectWindow::Create() {
+ return scoped_ptr<DisconnectWindow>(new DisconnectWindowLinux());
}
} // namespace remoting
diff --git a/remoting/host/disconnect_window_mac.mm b/remoting/host/disconnect_window_mac.mm
index c3de197..f6f5e9a 100644
--- a/remoting/host/disconnect_window_mac.mm
+++ b/remoting/host/disconnect_window_mac.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -54,8 +54,8 @@ void DisconnectWindowMac::Hide() {
window_controller_ = nil;
}
-remoting::DisconnectWindow* remoting::DisconnectWindow::Create() {
- return new DisconnectWindowMac;
+scoped_ptr<DisconnectWindow> DisconnectWindow::Create() {
+ return scoped_ptr<DisconnectWindow>(new DisconnectWindowMac());
}
} // namespace remoting
diff --git a/remoting/host/disconnect_window_win.cc b/remoting/host/disconnect_window_win.cc
index a9f7742..42e703f 100644
--- a/remoting/host/disconnect_window_win.cc
+++ b/remoting/host/disconnect_window_win.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -290,8 +290,8 @@ void DisconnectWindowWin::EndDialog(int result) {
}
}
-DisconnectWindow* DisconnectWindow::Create() {
- return new DisconnectWindowWin;
+scoped_ptr<DisconnectWindow> DisconnectWindow::Create() {
+ return scoped_ptr<DisconnectWindow>(new DisconnectWindowWin());
}
} // namespace remoting
diff --git a/remoting/host/event_executor.h b/remoting/host/event_executor.h
index 70727d0..3acde7a 100644
--- a/remoting/host/event_executor.h
+++ b/remoting/host/event_executor.h
@@ -17,7 +17,6 @@ class Capturer;
class EventExecutor : public protocol::HostEventStub {
public:
// Creates default event executor for the current platform.
- // Does not take ownership of |message_loop| or |capturer|.
static scoped_ptr<protocol::HostEventStub> Create(MessageLoop* message_loop,
Capturer* capturer);
};
diff --git a/remoting/host/heartbeat_sender.h b/remoting/host/heartbeat_sender.h
index 9f48f78..92425fe 100644
--- a/remoting/host/heartbeat_sender.h
+++ b/remoting/host/heartbeat_sender.h
@@ -79,9 +79,9 @@ class IqSender;
// </iq>
class HeartbeatSender : public SignalStrategy::Listener {
public:
- // Doesn't take ownership of |signal_strategy| or |key_pair|. Both
- // parameters must outlive this object. Heartbeats will start when
- // the supplied SignalStrategy enters the CONNECTED state.
+ // |signal_strategy| and |key_pair| must outlive this
+ // object. Heartbeats will start when the supplied SignalStrategy
+ // enters the CONNECTED state.
HeartbeatSender(const std::string& host_id,
SignalStrategy* signal_strategy,
HostKeyPair* key_pair);
diff --git a/remoting/host/host_mock_objects.cc b/remoting/host/host_mock_objects.cc
index 5144e7e..91152d0 100644
--- a/remoting/host/host_mock_objects.cc
+++ b/remoting/host/host_mock_objects.cc
@@ -30,24 +30,24 @@ MockDisconnectWindow::MockDisconnectWindow() {}
MockDisconnectWindow::~MockDisconnectWindow() {}
-DisconnectWindow* DisconnectWindow::Create() {
- return new MockDisconnectWindow();
+scoped_ptr<DisconnectWindow> DisconnectWindow::Create() {
+ return scoped_ptr<DisconnectWindow>(new MockDisconnectWindow());
}
MockContinueWindow::MockContinueWindow() {}
MockContinueWindow::~MockContinueWindow() {}
-ContinueWindow* ContinueWindow::Create() {
- return new MockContinueWindow();
+scoped_ptr<ContinueWindow> ContinueWindow::Create() {
+ return scoped_ptr<ContinueWindow>(new MockContinueWindow());
}
MockLocalInputMonitor::MockLocalInputMonitor() {}
MockLocalInputMonitor::~MockLocalInputMonitor() {}
-LocalInputMonitor* LocalInputMonitor::Create() {
- return new MockLocalInputMonitor();
+scoped_ptr<LocalInputMonitor> LocalInputMonitor::Create() {
+ return scoped_ptr<LocalInputMonitor>(new MockLocalInputMonitor());
}
MockChromotingHostContext::MockChromotingHostContext()
diff --git a/remoting/host/it2me_host_user_interface.cc b/remoting/host/it2me_host_user_interface.cc
index dbde578..758bafa 100644
--- a/remoting/host/it2me_host_user_interface.cc
+++ b/remoting/host/it2me_host_user_interface.cc
@@ -44,12 +44,13 @@ void It2MeHostUserInterface::Init() {
LocalInputMonitor::Create());
}
-void It2MeHostUserInterface::InitFrom(DisconnectWindow* disconnect_window,
- ContinueWindow* continue_window,
- LocalInputMonitor* monitor) {
- disconnect_window_.reset(disconnect_window);
- continue_window_.reset(continue_window);
- local_input_monitor_.reset(monitor);
+void It2MeHostUserInterface::InitFrom(
+ scoped_ptr<DisconnectWindow> disconnect_window,
+ scoped_ptr<ContinueWindow> continue_window,
+ scoped_ptr<LocalInputMonitor> monitor) {
+ disconnect_window_ = disconnect_window.Pass();
+ continue_window_ = continue_window.Pass();
+ local_input_monitor_ = monitor.Pass();
host_->AddStatusObserver(this);
}
diff --git a/remoting/host/it2me_host_user_interface.h b/remoting/host/it2me_host_user_interface.h
index 64f3522..897ddd7 100644
--- a/remoting/host/it2me_host_user_interface.h
+++ b/remoting/host/it2me_host_user_interface.h
@@ -58,11 +58,10 @@ class It2MeHostUserInterface : public HostStatusObserver {
friend class ChromotingHostTest;
// Used by unit-tests as an alternative to Init() so that mock versions of
- // internal objects can be used. This takes ownership of all objects passed
- // in.
- void InitFrom(DisconnectWindow* disconnect_window,
- ContinueWindow* continue_window,
- LocalInputMonitor* monitor);
+ // internal objects can be used.
+ void InitFrom(scoped_ptr<DisconnectWindow> disconnect_window,
+ scoped_ptr<ContinueWindow> continue_window,
+ scoped_ptr<LocalInputMonitor> monitor);
void ProcessOnClientAuthenticated(const std::string& username);
void ProcessOnClientDisconnected();
diff --git a/remoting/host/local_input_monitor.h b/remoting/host/local_input_monitor.h
index 7c2b9d5..8e05700 100644
--- a/remoting/host/local_input_monitor.h
+++ b/remoting/host/local_input_monitor.h
@@ -1,10 +1,12 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef REMOTING_LOCAL_INPUT_MONITOR_H_
#define REMOTING_LOCAL_INPUT_MONITOR_H_
+#include "base/memory/scoped_ptr.h"
+
namespace remoting {
class ChromotingHost;
@@ -16,7 +18,7 @@ class LocalInputMonitor {
virtual void Start(ChromotingHost* host) = 0;
virtual void Stop() = 0;
- static LocalInputMonitor* Create();
+ static scoped_ptr<LocalInputMonitor> Create();
};
} // namespace remoting
diff --git a/remoting/host/local_input_monitor_linux.cc b/remoting/host/local_input_monitor_linux.cc
index c6e8037..1785a96 100644
--- a/remoting/host/local_input_monitor_linux.cc
+++ b/remoting/host/local_input_monitor_linux.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,23 +8,22 @@
#include "base/compiler_specific.h"
#include "base/logging.h"
+namespace remoting {
+
namespace {
-class LocalInputMonitorLinux : public remoting::LocalInputMonitor {
+class LocalInputMonitorLinux : public LocalInputMonitor {
public:
LocalInputMonitorLinux();
~LocalInputMonitorLinux();
- virtual void Start(remoting::ChromotingHost* host) OVERRIDE;
+ virtual void Start(ChromotingHost* host) OVERRIDE;
virtual void Stop() OVERRIDE;
private:
- remoting::LocalInputMonitorThread* thread_;
+ LocalInputMonitorThread* thread_;
};
-} // namespace
-
-
LocalInputMonitorLinux::LocalInputMonitorLinux()
: thread_(NULL) {
}
@@ -33,9 +32,9 @@ LocalInputMonitorLinux::~LocalInputMonitorLinux() {
CHECK(!thread_);
}
-void LocalInputMonitorLinux::Start(remoting::ChromotingHost* host) {
+void LocalInputMonitorLinux::Start(ChromotingHost* host) {
CHECK(!thread_);
- thread_ = new remoting::LocalInputMonitorThread(host);
+ thread_ = new LocalInputMonitorThread(host);
thread_->Start();
}
@@ -47,6 +46,10 @@ void LocalInputMonitorLinux::Stop() {
thread_ = 0;
}
-remoting::LocalInputMonitor* remoting::LocalInputMonitor::Create() {
- return new LocalInputMonitorLinux;
+} // namespace
+
+scoped_ptr<LocalInputMonitor> LocalInputMonitor::Create() {
+ return scoped_ptr<LocalInputMonitor>(new LocalInputMonitorLinux());
}
+
+} // namespace remoting
diff --git a/remoting/host/local_input_monitor_mac.mm b/remoting/host/local_input_monitor_mac.mm
index 57c7053..b25496f 100644
--- a/remoting/host/local_input_monitor_mac.mm
+++ b/remoting/host/local_input_monitor_mac.mm
@@ -143,17 +143,19 @@ static CGEventRef LocalMouseMoved(CGEventTapProxy proxy, CGEventType type,
@end
+namespace remoting {
+
namespace {
-class LocalInputMonitorMac : public remoting::LocalInputMonitor {
+class LocalInputMonitorMac : public LocalInputMonitor {
public:
LocalInputMonitorMac() : host_(NULL) {}
virtual ~LocalInputMonitorMac();
- virtual void Start(remoting::ChromotingHost* host) OVERRIDE;
+ virtual void Start(ChromotingHost* host) OVERRIDE;
virtual void Stop() OVERRIDE;
private:
- remoting::ChromotingHost* host_;
+ ChromotingHost* host_;
DISALLOW_COPY_AND_ASSIGN(LocalInputMonitorMac);
};
@@ -166,7 +168,7 @@ LocalInputMonitorMac::~LocalInputMonitorMac() {
Stop();
}
-void LocalInputMonitorMac::Start(remoting::ChromotingHost* host) {
+void LocalInputMonitorMac::Start(ChromotingHost* host) {
base::AutoLock lock(monitor_lock.Get());
if (!local_input_monitor)
local_input_monitor = [[LocalInputMonitorImpl alloc] init];
@@ -184,6 +186,8 @@ void LocalInputMonitorMac::Stop() {
}
}
-remoting::LocalInputMonitor* remoting::LocalInputMonitor::Create() {
- return new LocalInputMonitorMac;
+scoped_ptr<LocalInputMonitor> LocalInputMonitor::Create() {
+ return scoped_ptr<LocalInputMonitor>(new LocalInputMonitorMac());
}
+
+} // namespace remoting
diff --git a/remoting/host/local_input_monitor_win.cc b/remoting/host/local_input_monitor_win.cc
index d728a50..08f73aa 100644
--- a/remoting/host/local_input_monitor_win.cc
+++ b/remoting/host/local_input_monitor_win.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,25 +9,24 @@
#include "remoting/host/chromoting_host.h"
#include "remoting/host/local_input_monitor_thread_win.h"
+namespace remoting {
+
namespace {
-class LocalInputMonitorWin : public remoting::LocalInputMonitor {
+class LocalInputMonitorWin : public LocalInputMonitor {
public:
LocalInputMonitorWin();
~LocalInputMonitorWin();
- virtual void Start(remoting::ChromotingHost* host) OVERRIDE;
+ virtual void Start(ChromotingHost* host) OVERRIDE;
virtual void Stop() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(LocalInputMonitorWin);
- remoting::ChromotingHost* chromoting_host_;
+ ChromotingHost* chromoting_host_;
};
-} // namespace
-
-
LocalInputMonitorWin::LocalInputMonitorWin() : chromoting_host_(NULL) {
}
@@ -35,19 +34,22 @@ LocalInputMonitorWin::~LocalInputMonitorWin() {
DCHECK(chromoting_host_ == NULL);
}
-void LocalInputMonitorWin::Start(remoting::ChromotingHost* host) {
+void LocalInputMonitorWin::Start(ChromotingHost* host) {
DCHECK(chromoting_host_ == NULL);
chromoting_host_ = host;
- remoting::LocalInputMonitorThread::AddHostToInputMonitor(chromoting_host_);
+ LocalInputMonitorThread::AddHostToInputMonitor(chromoting_host_);
}
void LocalInputMonitorWin::Stop() {
DCHECK(chromoting_host_ != NULL);
- remoting::LocalInputMonitorThread::RemoveHostFromInputMonitor(
- chromoting_host_);
+ LocalInputMonitorThread::RemoveHostFromInputMonitor(chromoting_host_);
chromoting_host_ = NULL;
}
-remoting::LocalInputMonitor* remoting::LocalInputMonitor::Create() {
- return new LocalInputMonitorWin;
+} // namespace
+
+scoped_ptr<LocalInputMonitor> LocalInputMonitor::Create() {
+ return scoped_ptr<LocalInputMonitor>(new LocalInputMonitorWin());
}
+
+} // namespace remoting
diff --git a/remoting/host/log_to_server.cc b/remoting/host/log_to_server.cc
index f75764a..47c4836 100644
--- a/remoting/host/log_to_server.cc
+++ b/remoting/host/log_to_server.cc
@@ -97,7 +97,7 @@ void LogToServer::SendPendingEntries() {
kChromotingXmlNamespace, kLogCommand)));
while (!pending_entries_.empty()) {
ServerLogEntry& entry = pending_entries_.front();
- stanza->AddElement(entry.ToStanza());
+ stanza->AddElement(entry.ToStanza().release());
pending_entries_.pop_front();
}
// Send the stanza to the server.
diff --git a/remoting/host/register_support_host_request.h b/remoting/host/register_support_host_request.h
index 86c4e07..8532534 100644
--- a/remoting/host/register_support_host_request.h
+++ b/remoting/host/register_support_host_request.h
@@ -41,7 +41,6 @@ class RegisterSupportHostRequest : public SignalStrategy::Listener {
typedef base::Callback<void(bool, const std::string&,
const base::TimeDelta&)> RegisterCallback;
- // Doesn't take ownership of |signal_strategy| or |key_pair|. Both
// |signal_strategy| and |key_pair| must outlive this
// object. |callback| is called when registration response is
// received from the server. Callback is never called if the bot
diff --git a/remoting/host/screen_recorder.cc b/remoting/host/screen_recorder.cc
index e332f27..7b0a886 100644
--- a/remoting/host/screen_recorder.cc
+++ b/remoting/host/screen_recorder.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -234,42 +234,30 @@ void ScreenRecorder::DoInvalidateFullScreen() {
// Network thread --------------------------------------------------------------
-void ScreenRecorder::DoSendVideoPacket(VideoPacket* packet) {
+void ScreenRecorder::DoSendVideoPacket(scoped_ptr<VideoPacket> packet) {
DCHECK(network_loop_->BelongsToCurrentThread());
- bool last = (packet->flags() & VideoPacket::LAST_PARTITION) != 0;
-
- if (network_stopped_ || connections_.empty()) {
- delete packet;
+ if (network_stopped_ || connections_.empty())
return;
- }
- for (ConnectionToClientList::const_iterator i = connections_.begin();
- i < connections_.end(); ++i) {
- base::Closure done_task;
-
- // Call FrameSentCallback() only for the last packet in the first
- // connection.
- if (last && i == connections_.begin()) {
- done_task = base::Bind(&ScreenRecorder::FrameSentCallback, this, packet);
- } else {
- // TODO(hclam): Fix this code since it causes multiple deletion if there's
- // more than one connection.
- done_task = base::Bind(&base::DeletePointer<VideoPacket>, packet);
- }
-
- (*i)->video_stub()->ProcessVideoPacket(packet, done_task);
- }
+ // TODO(sergeyu): Currently we send the data only to the first
+ // connection. Send it to all connections if necessary.
+ connections_.front()->video_stub()->ProcessVideoPacket(
+ packet.get(), base::Bind(
+ &ScreenRecorder::VideoPacketSentCallback, this,
+ base::Passed(packet.Pass())));
}
-void ScreenRecorder::FrameSentCallback(VideoPacket* packet) {
- delete packet;
-
+void ScreenRecorder::VideoPacketSentCallback(scoped_ptr<VideoPacket> packet) {
if (network_stopped_)
return;
- capture_loop_->PostTask(
- FROM_HERE, base::Bind(&ScreenRecorder::DoFinishOneRecording, this));
+ if ((packet->flags() & VideoPacket::LAST_PARTITION) != 0) {
+ // Post DoFinishOneRecording() if that was the last packet for the
+ // frame.
+ capture_loop_->PostTask(
+ FROM_HERE, base::Bind(&ScreenRecorder::DoFinishOneRecording, this));
+ }
}
void ScreenRecorder::DoStopOnNetworkThread(const base::Closure& done_task) {
@@ -297,11 +285,11 @@ void ScreenRecorder::DoEncode(
// Early out if there's nothing to encode.
if (!capture_data || capture_data->dirty_region().isEmpty()) {
// Send an empty video packet to keep network active.
- VideoPacket* packet = new VideoPacket();
+ scoped_ptr<VideoPacket> packet(new VideoPacket());
packet->set_flags(VideoPacket::LAST_PARTITION);
network_loop_->PostTask(
FROM_HERE, base::Bind(&ScreenRecorder::DoSendVideoPacket,
- this, packet));
+ this, base::Passed(packet.Pass())));
return;
}
@@ -322,7 +310,8 @@ void ScreenRecorder::DoStopOnEncodeThread(const base::Closure& done_task) {
capture_loop_->PostTask(FROM_HERE, done_task);
}
-void ScreenRecorder::EncodedDataAvailableCallback(VideoPacket* packet) {
+void ScreenRecorder::EncodedDataAvailableCallback(
+ scoped_ptr<VideoPacket> packet) {
DCHECK_EQ(encode_loop_, MessageLoop::current());
if (encoder_stopped_)
@@ -338,7 +327,8 @@ void ScreenRecorder::EncodedDataAvailableCallback(VideoPacket* packet) {
}
network_loop_->PostTask(
- FROM_HERE, base::Bind(&ScreenRecorder::DoSendVideoPacket, this, packet));
+ FROM_HERE, base::Bind(&ScreenRecorder::DoSendVideoPacket, this,
+ base::Passed(packet.Pass())));
}
} // namespace remoting
diff --git a/remoting/host/screen_recorder.h b/remoting/host/screen_recorder.h
index 95e338a..c6554e4 100644
--- a/remoting/host/screen_recorder.h
+++ b/remoting/host/screen_recorder.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -125,9 +125,7 @@ class ScreenRecorder : public base::RefCountedThreadSafe<ScreenRecorder> {
// Network thread -----------------------------------------------------------
- // DoSendVideoPacket takes ownership of the |packet| and is responsible
- // for deleting it.
- void DoSendVideoPacket(VideoPacket* packet);
+ void DoSendVideoPacket(scoped_ptr<VideoPacket> packet);
void DoSendInit(scoped_refptr<protocol::ConnectionToClient> connection,
int width, int height);
@@ -135,9 +133,8 @@ class ScreenRecorder : public base::RefCountedThreadSafe<ScreenRecorder> {
// Signal network thread to cease activities.
void DoStopOnNetworkThread(const base::Closure& done_task);
- // Callback for the last packet in one update. Deletes |packet| and
- // schedules next screen capture.
- void FrameSentCallback(VideoPacket* packet);
+ // Callback for VideoStub::ProcessVideoPacket().
+ void VideoPacketSentCallback(scoped_ptr<VideoPacket> packet);
// Encoder thread -----------------------------------------------------------
@@ -146,8 +143,7 @@ class ScreenRecorder : public base::RefCountedThreadSafe<ScreenRecorder> {
// Perform stop operations on encode thread.
void DoStopOnEncodeThread(const base::Closure& done_task);
- // EncodedDataAvailableCallback takes ownership of |packet|.
- void EncodedDataAvailableCallback(VideoPacket* packet);
+ void EncodedDataAvailableCallback(scoped_ptr<VideoPacket> packet);
void SendVideoPacket(VideoPacket* packet);
// Message loops used by this class.
diff --git a/remoting/host/screen_recorder_unittest.cc b/remoting/host/screen_recorder_unittest.cc
index ae9e636..cb2c7bc 100644
--- a/remoting/host/screen_recorder_unittest.cc
+++ b/remoting/host/screen_recorder_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -42,7 +42,7 @@ ACTION_P2(RunCallback, region, data) {
ACTION(FinishEncode) {
scoped_ptr<VideoPacket> packet(new VideoPacket());
packet->set_flags(VideoPacket::LAST_PACKET | VideoPacket::LAST_PARTITION);
- arg2.Run(packet.release());
+ arg2.Run(packet.Pass());
}
ACTION(FinishSend) {
diff --git a/remoting/host/server_log_entry.cc b/remoting/host/server_log_entry.cc
index 6e1a267..18f85c7 100644
--- a/remoting/host/server_log_entry.cc
+++ b/remoting/host/server_log_entry.cc
@@ -102,14 +102,14 @@ const char* ServerLogEntry::GetValueMode(ServerLogEntry::Mode mode) {
}
}
-XmlElement* ServerLogEntry::ToStanza() const {
- XmlElement* stanza = new XmlElement(QName(
- kChromotingXmlNamespace, kLogEntry));
+scoped_ptr<XmlElement> ServerLogEntry::ToStanza() const {
+ scoped_ptr<XmlElement> stanza(new XmlElement(QName(
+ kChromotingXmlNamespace, kLogEntry)));
ValuesMap::const_iterator iter;
for (iter = values_map_.begin(); iter != values_map_.end(); ++iter) {
stanza->AddAttr(QName("", iter->first), iter->second);
}
- return stanza;
+ return stanza.Pass();
}
const char* ServerLogEntry::GetValueSessionState(bool connected) {
diff --git a/remoting/host/server_log_entry.h b/remoting/host/server_log_entry.h
index 3353569..a1c090c 100644
--- a/remoting/host/server_log_entry.h
+++ b/remoting/host/server_log_entry.h
@@ -8,6 +8,8 @@
#include <map>
#include <string>
+#include "base/memory/scoped_ptr.h"
+
namespace buzz {
class XmlElement;
} // namespace buzz
@@ -35,8 +37,7 @@ class ServerLogEntry {
void AddModeField(Mode mode);
// Converts this object to an XML stanza.
- // The caller takes ownership of the stanza.
- buzz::XmlElement* ToStanza() const;
+ scoped_ptr<buzz::XmlElement> ToStanza() const;
private:
typedef std::map<std::string, std::string> ValuesMap;
diff --git a/remoting/host/server_log_entry_unittest.cc b/remoting/host/server_log_entry_unittest.cc
index 55c676c..5cd94ee 100644
--- a/remoting/host/server_log_entry_unittest.cc
+++ b/remoting/host/server_log_entry_unittest.cc
@@ -63,7 +63,7 @@ class ServerLogEntryTest : public testing::Test {
TEST_F(ServerLogEntryTest, MakeSessionStateChange) {
scoped_ptr<ServerLogEntry> entry(
ServerLogEntry::MakeSessionStateChange(true));
- scoped_ptr<XmlElement> stanza(entry->ToStanza());
+ scoped_ptr<XmlElement> stanza = entry->ToStanza();
std::string error;
std::map<std::string, std::string> key_value_pairs;
key_value_pairs["role"] = "host";
@@ -78,7 +78,7 @@ TEST_F(ServerLogEntryTest, AddHostFields) {
scoped_ptr<ServerLogEntry> entry(
ServerLogEntry::MakeSessionStateChange(true));
entry->AddHostFields();
- scoped_ptr<XmlElement> stanza(entry->ToStanza());
+ scoped_ptr<XmlElement> stanza = entry->ToStanza();
std::string error;
std::map<std::string, std::string> key_value_pairs;
key_value_pairs["role"] = "host";
@@ -106,7 +106,7 @@ TEST_F(ServerLogEntryTest, AddModeField1) {
scoped_ptr<ServerLogEntry> entry(
ServerLogEntry::MakeSessionStateChange(true));
entry->AddModeField(ServerLogEntry::IT2ME);
- scoped_ptr<XmlElement> stanza(entry->ToStanza());
+ scoped_ptr<XmlElement> stanza = entry->ToStanza();
std::string error;
std::map<std::string, std::string> key_value_pairs;
key_value_pairs["role"] = "host";
@@ -122,7 +122,7 @@ TEST_F(ServerLogEntryTest, AddModeField2) {
scoped_ptr<ServerLogEntry> entry(
ServerLogEntry::MakeSessionStateChange(true));
entry->AddModeField(ServerLogEntry::ME2ME);
- scoped_ptr<XmlElement> stanza(entry->ToStanza());
+ scoped_ptr<XmlElement> stanza = entry->ToStanza();
std::string error;
std::map<std::string, std::string> key_value_pairs;
key_value_pairs["role"] = "host";