OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_LOADER_RENDER_VIEW_HOST_TRACKER_H_ |
| 6 #define CONTENT_BROWSER_LOADER_RENDER_VIEW_HOST_TRACKER_H_ |
| 7 |
| 8 #include <set> |
| 9 |
| 10 #include "content/public/browser/notification_observer.h" |
| 11 #include "content/public/browser/notification_registrar.h" |
| 12 #include "content/public/browser/render_view_host_observer.h" |
| 13 |
| 14 namespace content { |
| 15 |
| 16 // The ResourceDispatcherHost needs to know when renderers are created and |
| 17 // destroyed. That happens on the UI thread, but the ResourceDispatcherHost |
| 18 // operates on the IO thread. RenderViewHostTracker listens for renderer |
| 19 // notifications on the UI thread, then bounces them over to the IO thread so |
| 20 // the ResourceDispatcherHost can be notified. |
| 21 class CONTENT_EXPORT RenderViewHostTracker : public NotificationObserver { |
| 22 public: |
| 23 RenderViewHostTracker(); |
| 24 virtual ~RenderViewHostTracker(); |
| 25 |
| 26 private: |
| 27 class Observer : public RenderViewHostObserver { |
| 28 public: |
| 29 Observer(RenderViewHost* rvh, |
| 30 RenderViewHostTracker* tracker); |
| 31 virtual ~Observer(); |
| 32 |
| 33 private: |
| 34 // RenderViewHostObserver interface: |
| 35 virtual void RenderViewHostDestroyed(RenderViewHost* rvh) OVERRIDE; |
| 36 |
| 37 RenderViewHostTracker* tracker_; |
| 38 }; |
| 39 |
| 40 friend class Observer; |
| 41 typedef std::set<Observer*> ObserverSet; |
| 42 |
| 43 // NotificationObserver interface: |
| 44 virtual void Observe(int type, |
| 45 const NotificationSource& source, |
| 46 const NotificationDetails& details) OVERRIDE; |
| 47 |
| 48 void RemoveObserver(Observer* observer); |
| 49 |
| 50 content::NotificationRegistrar registrar_; |
| 51 ObserverSet observers_; |
| 52 }; |
| 53 |
| 54 } // namespace content |
| 55 |
| 56 #endif // CONTENT_BROWSER_LOADER_RENDER_VIEW_HOST_TRACKER_H_ |
OLD | NEW |