Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1170)

Side by Side Diff: content/browser/renderer_host/render_widget_host_unittest.cc

Issue 253913003: Remove RenderWidgetHostView*::DidUpdateBackingStore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/timer/timer.h" 10 #include "base/timer/timer.h"
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 }; 348 };
349 349
350 namespace { 350 namespace {
351 351
352 // RenderWidgetHostProcess ----------------------------------------------------- 352 // RenderWidgetHostProcess -----------------------------------------------------
353 353
354 class RenderWidgetHostProcess : public MockRenderProcessHost { 354 class RenderWidgetHostProcess : public MockRenderProcessHost {
355 public: 355 public:
356 explicit RenderWidgetHostProcess(BrowserContext* browser_context) 356 explicit RenderWidgetHostProcess(BrowserContext* browser_context)
357 : MockRenderProcessHost(browser_context), 357 : MockRenderProcessHost(browser_context),
358 current_update_buf_(NULL),
359 update_msg_should_reply_(false), 358 update_msg_should_reply_(false),
360 update_msg_reply_flags_(0) { 359 update_msg_reply_flags_(0) {
361 } 360 }
362 virtual ~RenderWidgetHostProcess() { 361 virtual ~RenderWidgetHostProcess() {
363 delete current_update_buf_;
364 } 362 }
365 363
366 void set_update_msg_should_reply(bool reply) { 364 void set_update_msg_should_reply(bool reply) {
367 update_msg_should_reply_ = reply; 365 update_msg_should_reply_ = reply;
368 } 366 }
369 void set_update_msg_reply_flags(int flags) { 367 void set_update_msg_reply_flags(int flags) {
370 update_msg_reply_flags_ = flags; 368 update_msg_reply_flags_ = flags;
371 } 369 }
372 370
373 // Fills the given update parameters with resonable default values. 371 // Fills the given update parameters with resonable default values.
374 void InitUpdateRectParams(ViewHostMsg_UpdateRect_Params* params); 372 void InitUpdateRectParams(ViewHostMsg_UpdateRect_Params* params);
375 373
376 virtual bool HasConnection() const OVERRIDE { return true; } 374 virtual bool HasConnection() const OVERRIDE { return true; }
377 375
378 protected: 376 protected:
379 virtual bool WaitForBackingStoreMsg(int render_widget_id, 377 virtual bool WaitForBackingStoreMsg(int render_widget_id,
380 const base::TimeDelta& max_delay, 378 const base::TimeDelta& max_delay,
381 IPC::Message* msg) OVERRIDE; 379 IPC::Message* msg) OVERRIDE;
382 380
383 TransportDIB* current_update_buf_;
384
385 // Set to true when WaitForBackingStoreMsg should return a successful update 381 // Set to true when WaitForBackingStoreMsg should return a successful update
386 // message reply. False implies timeout. 382 // message reply. False implies timeout.
387 bool update_msg_should_reply_; 383 bool update_msg_should_reply_;
388 384
389 // Indicates the flags that should be sent with a repaint request. This 385 // Indicates the flags that should be sent with a repaint request. This
390 // only has an effect when update_msg_should_reply_ is true. 386 // only has an effect when update_msg_should_reply_ is true.
391 int update_msg_reply_flags_; 387 int update_msg_reply_flags_;
392 388
393 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostProcess); 389 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostProcess);
394 }; 390 };
395 391
396 void RenderWidgetHostProcess::InitUpdateRectParams( 392 void RenderWidgetHostProcess::InitUpdateRectParams(
397 ViewHostMsg_UpdateRect_Params* params) { 393 ViewHostMsg_UpdateRect_Params* params) {
398 // Create the shared backing store.
399 const int w = 100, h = 100; 394 const int w = 100, h = 100;
400 const size_t pixel_size = w * h * 4;
401 395
402 if (!current_update_buf_)
403 current_update_buf_ = TransportDIB::Create(pixel_size, 0);
404 params->bitmap = current_update_buf_->id();
405 params->bitmap_rect = gfx::Rect(0, 0, w, h);
406 params->scroll_delta = gfx::Vector2d();
407 params->copy_rects.push_back(params->bitmap_rect);
408 params->view_size = gfx::Size(w, h); 396 params->view_size = gfx::Size(w, h);
397 params->copy_rects.push_back(gfx::Rect(params->view_size));
409 params->flags = update_msg_reply_flags_; 398 params->flags = update_msg_reply_flags_;
410 params->scale_factor = 1;
411 } 399 }
412 400
413 bool RenderWidgetHostProcess::WaitForBackingStoreMsg( 401 bool RenderWidgetHostProcess::WaitForBackingStoreMsg(
414 int render_widget_id, 402 int render_widget_id,
415 const base::TimeDelta& max_delay, 403 const base::TimeDelta& max_delay,
416 IPC::Message* msg) { 404 IPC::Message* msg) {
417 if (!update_msg_should_reply_) 405 if (!update_msg_should_reply_)
418 return false; 406 return false;
419 407
420 // Construct a fake update reply. 408 // Construct a fake update reply.
(...skipping 2271 matching lines...) Expand 10 before | Expand all | Expand 10 after
2692 2680
2693 // Tests RWHI::ForwardTouchEventWithLatencyInfo(). 2681 // Tests RWHI::ForwardTouchEventWithLatencyInfo().
2694 PressTouchPoint(0, 1); 2682 PressTouchPoint(0, 1);
2695 SendTouchEvent(); 2683 SendTouchEvent();
2696 CheckLatencyInfoComponentInMessage( 2684 CheckLatencyInfoComponentInMessage(
2697 process_, GetLatencyComponentId(), WebInputEvent::TouchStart); 2685 process_, GetLatencyComponentId(), WebInputEvent::TouchStart);
2698 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); 2686 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED);
2699 } 2687 }
2700 2688
2701 } // namespace content 2689 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698