Skip to content

Commit

Permalink
Clean up remoting project
Browse files Browse the repository at this point in the history
Cleaned up some file names so it simplifies our project, and gets us more inline with chromium standards.
Removed several unnecessary headers that were cluttering the remoting namespace.
Simplified some of the double pimpl implementations that we had on Linux to hide X11 stuff.
Got HostAuthentication working reasonably well as a mock.

BUG=NONE
TEST=BUILD

Review URL: http://codereview.chromium.org/6780014

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80385 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
dmaclach@chromium.org committed Apr 4, 2011
1 parent 167d52b commit 0b7e428
Show file tree
Hide file tree
Showing 43 changed files with 723 additions and 1,036 deletions.
112 changes: 0 additions & 112 deletions remoting/host/capturer_gdi.h

This file was deleted.

110 changes: 38 additions & 72 deletions remoting/host/capturer_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,44 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "remoting/host/capturer_linux.h"
#include "remoting/host/capturer.h"

#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/Xdamage.h>

#include <set>

#include "base/basictypes.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "remoting/base/types.h"
#include "remoting/host/capturer_helper.h"
#include "remoting/host/x_server_pixel_buffer.h"

namespace remoting {

// Private Implementation pattern to avoid leaking the X11 types into the header
// file.
class CapturerLinuxPimpl : public Capturer {
namespace {

// A class to perform capturing for Linux.
class CapturerLinux : public Capturer {
public:
CapturerLinuxPimpl();
virtual ~CapturerLinuxPimpl();
CapturerLinux();
virtual ~CapturerLinux();

bool Init(); // TODO(ajwong): Do we really want this to be synchronous?

// Capturer interface.
virtual void ScreenConfigurationChanged();
virtual media::VideoFrame::Format pixel_format() const;
virtual void ClearInvalidRects();
virtual void InvalidateRects(const InvalidRects& inval_rects);
virtual void InvalidateScreen(const gfx::Size& size);
virtual void InvalidateFullScreen();
virtual void CaptureInvalidRects(CaptureCompletedCallback* callback);
virtual const gfx::Size& size_most_recent() const;
virtual void ScreenConfigurationChanged() OVERRIDE;
virtual media::VideoFrame::Format pixel_format() const OVERRIDE;
virtual void ClearInvalidRects() OVERRIDE;
virtual void InvalidateRects(const InvalidRects& inval_rects) OVERRIDE;
virtual void InvalidateScreen(const gfx::Size& size) OVERRIDE;
virtual void InvalidateFullScreen() OVERRIDE;
virtual void CaptureInvalidRects(CaptureCompletedCallback* callback) OVERRIDE;
virtual const gfx::Size& size_most_recent() const OVERRIDE;

private:
bool Init(); // TODO(ajwong): Do we really want this to be synchronous?
void CalculateInvalidRects();
void CaptureRects(const InvalidRects& rects,
Capturer::CaptureCompletedCallback* callback);
Expand Down Expand Up @@ -84,51 +87,11 @@ class CapturerLinuxPimpl : public Capturer {

// Last capture buffer used.
uint8* last_buffer_;

DISALLOW_COPY_AND_ASSIGN(CapturerLinux);
};

CapturerLinux::CapturerLinux()
: pimpl_(new CapturerLinuxPimpl()) {
// TODO(ajwong): This should be moved into an Init() method on Capturer
// itself. Then we can remove the CHECK.
CHECK(pimpl_->Init());
}

CapturerLinux::~CapturerLinux() {
}

void CapturerLinux::ScreenConfigurationChanged() {
pimpl_->ScreenConfigurationChanged();
}

media::VideoFrame::Format CapturerLinux::pixel_format() const {
return pimpl_->pixel_format();
}

void CapturerLinux::ClearInvalidRects() {
pimpl_->ClearInvalidRects();
}

void CapturerLinux::InvalidateRects(const InvalidRects& inval_rects) {
pimpl_->InvalidateRects(inval_rects);
}

void CapturerLinux::InvalidateScreen(const gfx::Size& size) {
pimpl_->InvalidateScreen(size);
}

void CapturerLinux::InvalidateFullScreen() {
pimpl_->InvalidateFullScreen();
}

void CapturerLinux::CaptureInvalidRects(CaptureCompletedCallback* callback) {
pimpl_->CaptureInvalidRects(callback);
}

const gfx::Size& CapturerLinux::size_most_recent() const {
return pimpl_->size_most_recent();
}

CapturerLinuxPimpl::CapturerLinuxPimpl()
: display_(NULL),
gc_(NULL),
root_window_(BadValue),
Expand All @@ -145,9 +108,10 @@ CapturerLinuxPimpl::CapturerLinuxPimpl()
for (int i = 0; i < kNumBuffers; i++) {
buffers_[i] = NULL;
}
CHECK(Init());
}

CapturerLinuxPimpl::~CapturerLinuxPimpl() {
CapturerLinux::~CapturerLinux() {
DeinitXlib();

for (int i = 0; i < kNumBuffers; i++) {
Expand All @@ -156,7 +120,7 @@ CapturerLinuxPimpl::~CapturerLinuxPimpl() {
}
}

bool CapturerLinuxPimpl::Init() {
bool CapturerLinux::Init() {
// TODO(ajwong): We should specify the display string we are attaching to
// in the constructor.
display_ = XOpenDisplay(NULL);
Expand Down Expand Up @@ -216,32 +180,32 @@ bool CapturerLinuxPimpl::Init() {
return true;
}

void CapturerLinuxPimpl::ScreenConfigurationChanged() {
void CapturerLinux::ScreenConfigurationChanged() {
// TODO(ajwong): Support resolution changes.
NOTIMPLEMENTED();
}

media::VideoFrame::Format CapturerLinuxPimpl::pixel_format() const {
media::VideoFrame::Format CapturerLinux::pixel_format() const {
return pixel_format_;
}

void CapturerLinuxPimpl::ClearInvalidRects() {
void CapturerLinux::ClearInvalidRects() {
helper_.ClearInvalidRects();
}

void CapturerLinuxPimpl::InvalidateRects(const InvalidRects& inval_rects) {
void CapturerLinux::InvalidateRects(const InvalidRects& inval_rects) {
helper_.InvalidateRects(inval_rects);
}

void CapturerLinuxPimpl::InvalidateScreen(const gfx::Size& size) {
void CapturerLinux::InvalidateScreen(const gfx::Size& size) {
helper_.InvalidateScreen(size);
}

void CapturerLinuxPimpl::InvalidateFullScreen() {
void CapturerLinux::InvalidateFullScreen() {
helper_.InvalidateFullScreen();
}

void CapturerLinuxPimpl::CaptureInvalidRects(
void CapturerLinux::CaptureInvalidRects(
CaptureCompletedCallback* callback) {
CalculateInvalidRects();

Expand All @@ -251,7 +215,7 @@ void CapturerLinuxPimpl::CaptureInvalidRects(
CaptureRects(rects, callback);
}

void CapturerLinuxPimpl::CalculateInvalidRects() {
void CapturerLinux::CalculateInvalidRects() {
if (helper_.IsCaptureFullScreen(gfx::Size(width_, height_)))
capture_fullscreen_ = true;

Expand Down Expand Up @@ -294,7 +258,7 @@ void CapturerLinuxPimpl::CalculateInvalidRects() {
}
}

void CapturerLinuxPimpl::CaptureRects(
void CapturerLinux::CaptureRects(
const InvalidRects& rects,
Capturer::CaptureCompletedCallback* callback) {
scoped_ptr<CaptureCompletedCallback> callback_deleter(callback);
Expand Down Expand Up @@ -354,7 +318,7 @@ void CapturerLinuxPimpl::CaptureRects(
callback->Run(capture_data);
}

void CapturerLinuxPimpl::DeinitXlib() {
void CapturerLinux::DeinitXlib() {
if (gc_) {
XFreeGC(display_, gc_);
gc_ = NULL;
Expand All @@ -366,7 +330,7 @@ void CapturerLinuxPimpl::DeinitXlib() {
}
}

void CapturerLinuxPimpl::FastBlit(uint8* image, const gfx::Rect& rect,
void CapturerLinux::FastBlit(uint8* image, const gfx::Rect& rect,
CaptureData* capture_data) {
uint8* src_pos = image;
int src_stride = x_server_pixel_buffer_.GetStride();
Expand All @@ -388,7 +352,7 @@ void CapturerLinuxPimpl::FastBlit(uint8* image, const gfx::Rect& rect,
}
}

void CapturerLinuxPimpl::SlowBlit(uint8* image, const gfx::Rect& rect,
void CapturerLinux::SlowBlit(uint8* image, const gfx::Rect& rect,
CaptureData* capture_data) {
DataPlanes planes = capture_data->data_planes();
uint8* dst_buffer = planes.data[0];
Expand Down Expand Up @@ -439,10 +403,12 @@ void CapturerLinuxPimpl::SlowBlit(uint8* image, const gfx::Rect& rect,
}
}

const gfx::Size& CapturerLinuxPimpl::size_most_recent() const {
const gfx::Size& CapturerLinux::size_most_recent() const {
return helper_.size_most_recent();
}

} // namespace

// static
Capturer* Capturer::Create() {
return new CapturerLinux();
Expand Down
41 changes: 0 additions & 41 deletions remoting/host/capturer_linux.h

This file was deleted.

4 changes: 2 additions & 2 deletions remoting/host/capturer_linux_unittest.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Copyright (c) 2011 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.

#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace remoting {

Expand Down
Loading

0 comments on commit 0b7e428

Please sign in to comment.