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> |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 // Callback to WebContentCreated(). Cached so that we can unregister it. | 397 // Callback to WebContentCreated(). Cached so that we can unregister it. |
398 base::Callback<void(WebContents*)> web_contents_created_callback_; | 398 base::Callback<void(WebContents*)> web_contents_created_callback_; |
399 | 399 |
400 WebContents* web_contents_; | 400 WebContents* web_contents_; |
401 scoped_ptr<RenderViewCreatedObserver> child_observer_; | 401 scoped_ptr<RenderViewCreatedObserver> child_observer_; |
402 scoped_refptr<MessageLoopRunner> runner_; | 402 scoped_refptr<MessageLoopRunner> runner_; |
403 | 403 |
404 DISALLOW_COPY_AND_ASSIGN(WebContentsAddedObserver); | 404 DISALLOW_COPY_AND_ASSIGN(WebContentsAddedObserver); |
405 }; | 405 }; |
406 | 406 |
| 407 // This observer keeps track of the last deleted RenderViewHost to avoid |
| 408 // accessing it and causing use-after-free condition. |
| 409 class RenderViewHostDeletedObserver : public WebContentsObserver { |
| 410 public: |
| 411 RenderViewHostDeletedObserver(RenderViewHost* rvh); |
| 412 ~RenderViewHostDeletedObserver() override; |
| 413 void RenderViewDeleted(RenderViewHost* render_view_host) override; |
| 414 bool deleted(); |
| 415 void WaitUntilDeleted(); |
| 416 |
| 417 private: |
| 418 int process_id_; |
| 419 int routing_id_; |
| 420 bool deleted_; |
| 421 scoped_ptr<base::RunLoop> runner_; |
| 422 |
| 423 DISALLOW_COPY_AND_ASSIGN(RenderViewHostDeletedObserver); |
| 424 }; |
| 425 |
| 426 // This observer keeps track of the last deleted RenderFrameHost to avoid |
| 427 // accessing it and causing use-after-free condition. |
| 428 class RenderFrameHostDeletedObserver : public WebContentsObserver { |
| 429 public: |
| 430 RenderFrameHostDeletedObserver(RenderFrameHost* rfh); |
| 431 ~RenderFrameHostDeletedObserver() override; |
| 432 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override; |
| 433 bool deleted(); |
| 434 void WaitUntilDeleted(); |
| 435 |
| 436 private: |
| 437 int process_id_; |
| 438 int routing_id_; |
| 439 bool deleted_; |
| 440 scoped_ptr<base::RunLoop> runner_; |
| 441 |
| 442 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostDeletedObserver); |
| 443 }; |
| 444 |
| 445 |
407 } // namespace content | 446 } // namespace content |
408 | 447 |
409 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 448 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
OLD | NEW |