| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_MANAGER_H_ |
| 6 #define CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_MANAGER_H_ | 6 #define CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/gtest_prod_util.h" |
| 10 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "content/public/browser/browser_plugin_guest_manager.h" | 13 #include "content/public/browser/browser_plugin_guest_manager.h" |
| 13 #include "content/public/browser/site_instance.h" | 14 #include "content/public/browser/site_instance.h" |
| 14 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 15 | 16 |
| 16 class GuestViewBase; | 17 class GuestViewBase; |
| 17 class GuestWebContentsObserver; | 18 class GuestWebContentsObserver; |
| 18 class GURL; | 19 class GURL; |
| 19 | 20 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 49 virtual void MaybeGetGuestByInstanceIDOrKill( | 50 virtual void MaybeGetGuestByInstanceIDOrKill( |
| 50 int guest_instance_id, | 51 int guest_instance_id, |
| 51 int embedder_render_process_id, | 52 int embedder_render_process_id, |
| 52 const GuestByInstanceIDCallback& callback) OVERRIDE; | 53 const GuestByInstanceIDCallback& callback) OVERRIDE; |
| 53 virtual bool ForEachGuest(content::WebContents* embedder_web_contents, | 54 virtual bool ForEachGuest(content::WebContents* embedder_web_contents, |
| 54 const GuestCallback& callback) OVERRIDE; | 55 const GuestCallback& callback) OVERRIDE; |
| 55 | 56 |
| 56 private: | 57 private: |
| 57 friend class GuestViewBase; | 58 friend class GuestViewBase; |
| 58 friend class GuestWebContentsObserver; | 59 friend class GuestWebContentsObserver; |
| 60 friend class TestGuestViewManager; |
| 61 FRIEND_TEST_ALL_PREFIXES(GuestViewManagerTest, AddRemove); |
| 59 | 62 |
| 60 void AddGuest(int guest_instance_id, | 63 // Returns true if adding the instance was successful. |
| 64 bool AddGuest(int guest_instance_id, |
| 61 content::WebContents* guest_web_contents); | 65 content::WebContents* guest_web_contents); |
| 62 | 66 |
| 63 void RemoveGuest(int guest_instance_id); | 67 void RemoveGuest(int guest_instance_id); |
| 64 | 68 |
| 65 void AddRenderProcessHostID(int render_process_host_id); | 69 void AddRenderProcessHostID(int render_process_host_id); |
| 66 | 70 |
| 67 content::SiteInstance* GetGuestSiteInstance( | 71 content::SiteInstance* GetGuestSiteInstance( |
| 68 const GURL& guest_site); | 72 const GURL& guest_site); |
| 69 | 73 |
| 70 content::WebContents* GetGuestByInstanceID( | 74 content::WebContents* GetGuestByInstanceID( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 82 GuestViewBase* guest); | 86 GuestViewBase* guest); |
| 83 | 87 |
| 84 // Counts RenderProcessHost IDs of GuestViewBases. | 88 // Counts RenderProcessHost IDs of GuestViewBases. |
| 85 std::multiset<int> render_process_host_id_multiset_; | 89 std::multiset<int> render_process_host_id_multiset_; |
| 86 | 90 |
| 87 // Contains guests' WebContents, mapping from their instance ids. | 91 // Contains guests' WebContents, mapping from their instance ids. |
| 88 typedef std::map<int, content::WebContents*> GuestInstanceMap; | 92 typedef std::map<int, content::WebContents*> GuestInstanceMap; |
| 89 GuestInstanceMap guest_web_contents_by_instance_id_; | 93 GuestInstanceMap guest_web_contents_by_instance_id_; |
| 90 | 94 |
| 91 int current_instance_id_; | 95 int current_instance_id_; |
| 96 |
| 97 // Any instance ID whose number not greater than this was removed via |
| 98 // RemoveGuest. |
| 99 // This is used so that we don't have store all removed instance IDs in |
| 100 // |removed_instance_ids_|. |
| 101 int last_instance_id_removed_; |
| 102 // The remaining instance IDs that are greater than |
| 103 // |last_instance_id_removed_| are kept here. |
| 104 std::set<int> removed_instance_ids_; |
| 105 |
| 92 content::BrowserContext* context_; | 106 content::BrowserContext* context_; |
| 93 | 107 |
| 94 DISALLOW_COPY_AND_ASSIGN(GuestViewManager); | 108 DISALLOW_COPY_AND_ASSIGN(GuestViewManager); |
| 95 }; | 109 }; |
| 96 | 110 |
| 97 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_MANAGER_H_ | 111 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_MANAGER_H_ |
| OLD | NEW |