Refactor the code in atom_api_web_contents

This commit is contained in:
Cheng Zhao 2016-08-03 12:29:55 +09:00
parent 921aaf9aa3
commit 9d8e510a55
4 changed files with 95 additions and 98 deletions

View file

@ -301,7 +301,7 @@ class AtomCopyFrameGenerator {
class AtomBeginFrameTimer : public cc::DelayBasedTimeSourceClient {
public:
AtomBeginFrameTimer(int frame_rate_threshold_ms,
const base::Closure& callback)
const base::Closure& callback)
: callback_(callback) {
time_source_ = cc::DelayBasedTimeSource::Create(
base::TimeDelta::FromMilliseconds(frame_rate_threshold_ms),
@ -341,7 +341,6 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
render_widget_host_(content::RenderWidgetHostImpl::From(host)),
native_window_(native_window),
software_output_device_(NULL),
callback_(nullptr),
frame_rate_(60),
frame_rate_threshold_ms_(0),
transparent_(transparent),
@ -450,7 +449,7 @@ bool OffScreenRenderWidgetHostView::OnMessageReceived(
}
void OffScreenRenderWidgetHostView::SetPaintCallback(
const OnPaintCallback* callback) {
const OnPaintCallback& callback) {
callback_ = callback;
}
@ -851,8 +850,9 @@ void OffScreenRenderWidgetHostView::OnPaint(
void* bitmap_pixels) {
TRACE_EVENT0("electron", "OffScreenRenderWidgetHostView::OnPaint");
if (callback_ != nullptr) {
callback_->Run(damage_rect, bitmap_width, bitmap_height, bitmap_pixels);
if (!callback_.is_null()) {
callback_.Run(damage_rect, gfx::Size(bitmap_width, bitmap_height),
bitmap_pixels);
}
}

View file

@ -195,7 +195,7 @@ class OffScreenRenderWidgetHostView:
void CreatePlatformWidget();
void DestroyPlatformWidget();
void SetPaintCallback(const atom::OnPaintCallback*);
void SetPaintCallback(const OnPaintCallback& callback);
void OnPaint(const gfx::Rect& damage_rect,
int bitmap_width,
@ -219,7 +219,7 @@ private:
OffScreenOutputDevice* software_output_device_;
const atom::OnPaintCallback* callback_;
const OnPaintCallback callback_;
int frame_rate_;
int frame_rate_threshold_ms_;