OLD | NEW |
---|---|
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 #ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/process/process.h" | 17 #include "base/process/process.h" |
18 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
20 #include "cc/output/compositor_frame.h" | |
20 #include "content/public/browser/browser_message_filter.h" | 21 #include "content/public/browser/browser_message_filter.h" |
21 #include "content/public/browser/notification_observer.h" | 22 #include "content/public/browser/notification_observer.h" |
22 #include "content/public/browser/notification_registrar.h" | 23 #include "content/public/browser/notification_registrar.h" |
23 #include "content/public/browser/render_process_host_observer.h" | 24 #include "content/public/browser/render_process_host_observer.h" |
24 #include "content/public/browser/web_contents_observer.h" | 25 #include "content/public/browser/web_contents_observer.h" |
25 #include "content/public/common/page_type.h" | 26 #include "content/public/common/page_type.h" |
26 #include "third_party/WebKit/public/web/WebInputEvent.h" | 27 #include "third_party/WebKit/public/web/WebInputEvent.h" |
27 #include "ui/events/keycodes/keyboard_codes.h" | 28 #include "ui/events/keycodes/keyboard_codes.h" |
28 #include "url/gurl.h" | 29 #include "url/gurl.h" |
29 | 30 |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
417 // synchronize the main thread against the impl thread. | 418 // synchronize the main thread against the impl thread. |
418 class FrameWatcher : public BrowserMessageFilter { | 419 class FrameWatcher : public BrowserMessageFilter { |
419 public: | 420 public: |
420 FrameWatcher(); | 421 FrameWatcher(); |
421 | 422 |
422 // Listen for new frames from the |web_contents| renderer process. | 423 // Listen for new frames from the |web_contents| renderer process. |
423 void AttachTo(WebContents* web_contents); | 424 void AttachTo(WebContents* web_contents); |
424 | 425 |
425 // Wait for |frames_to_wait| swap mesages from the compositor. | 426 // Wait for |frames_to_wait| swap mesages from the compositor. |
426 void WaitFrames(int frames_to_wait); | 427 void WaitFrames(int frames_to_wait); |
428 const cc::CompositorFrameMetadata& LastMetadata(); | |
427 | 429 |
428 private: | 430 private: |
429 ~FrameWatcher() override; | 431 ~FrameWatcher() override; |
430 | 432 |
431 // Overridden BrowserMessageFilter methods. | 433 // Overridden BrowserMessageFilter methods. |
432 bool OnMessageReceived(const IPC::Message& message) override; | 434 bool OnMessageReceived(const IPC::Message& message) override; |
433 | 435 |
434 void ReceivedFrameSwap(); | 436 void ReceivedFrameSwap(cc::CompositorFrameMetadata meta_data); |
435 | 437 |
436 int frames_to_wait_; | 438 int frames_to_wait_; |
437 base::Closure quit_; | 439 base::Closure quit_; |
440 cc::CompositorFrameMetadata last_metadata_; | |
438 | 441 |
439 DISALLOW_COPY_AND_ASSIGN(FrameWatcher); | 442 DISALLOW_COPY_AND_ASSIGN(FrameWatcher); |
440 }; | 443 }; |
441 | 444 |
442 // This class is intended to synchronize the renderer main thread, renderer impl | 445 // This class is intended to synchronize the renderer main thread, renderer impl |
443 // thread and the browser main thread. | 446 // thread and the browser main thread. |
444 class MainThreadFrameObserver : public IPC::Listener { | 447 class MainThreadFrameObserver : public IPC::Listener { |
445 public: | 448 public: |
446 explicit MainThreadFrameObserver(RenderWidgetHost* render_widget_host); | 449 explicit MainThreadFrameObserver(RenderWidgetHost* render_widget_host); |
447 ~MainThreadFrameObserver() override; | 450 ~MainThreadFrameObserver() override; |
448 | 451 |
449 // Synchronizes the browser main thread with the renderer main thread and impl | 452 // Synchronizes the browser main thread with the renderer main thread and impl |
450 // thread. | 453 // thread. |
451 void Wait(); | 454 void Wait(); |
452 | 455 |
453 // Overridden IPC::Listener methods. | 456 // Overridden IPC::Listener methods. |
454 bool OnMessageReceived(const IPC::Message& msg) override; | 457 bool OnMessageReceived(const IPC::Message& msg) override; |
455 | 458 |
456 private: | 459 private: |
457 void Quit(); | 460 void Quit(); |
458 | 461 |
459 RenderWidgetHost* render_widget_host_; | 462 RenderWidgetHost* render_widget_host_; |
460 scoped_ptr<base::RunLoop> run_loop_; | 463 scoped_ptr<base::RunLoop> run_loop_; |
461 int routing_id_; | 464 int routing_id_; |
462 | 465 |
463 DISALLOW_COPY_AND_ASSIGN(MainThreadFrameObserver); | 466 DISALLOW_COPY_AND_ASSIGN(MainThreadFrameObserver); |
464 }; | 467 }; |
465 | 468 |
469 // Watches for an input msg to be consumed. | |
470 class InputMsgWatcher : public BrowserMessageFilter { | |
471 public: | |
472 InputMsgWatcher(RenderWidgetHost* render_widget_host, | |
473 blink::WebInputEvent::Type type); | |
474 | |
475 // Wait for until ack message occurs; returning the ack result from | |
476 // the message. | |
477 uint32_t Wait(); | |
tdresser
2016/02/10 19:37:17
Perhaps WaitForAck?
dtapuska
2016/02/10 22:05:22
Done.
| |
478 | |
479 private: | |
480 ~InputMsgWatcher() override; | |
481 | |
482 // Overridden BrowserMessageFilter methods. | |
483 bool OnMessageReceived(const IPC::Message& message) override; | |
484 | |
485 void ReceivedAck(blink::WebInputEvent::Type ack_type, uint32_t ack_state); | |
486 | |
487 blink::WebInputEvent::Type wait_for_type_; | |
488 uint32_t ack_result_; | |
489 base::Closure quit_; | |
490 | |
491 DISALLOW_COPY_AND_ASSIGN(InputMsgWatcher); | |
492 }; | |
493 | |
466 } // namespace content | 494 } // namespace content |
467 | 495 |
468 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 496 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
OLD | NEW |