Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_CROSS_SITE_REQUEST_MANAGER_H__ | 5 #ifndef CHROME_BROWSER_CROSS_SITE_REQUEST_MANAGER_H__ |
| 6 #define CHROME_BROWSER_CROSS_SITE_REQUEST_MANAGER_H__ | 6 #define CHROME_BROWSER_CROSS_SITE_REQUEST_MANAGER_H__ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/lock.h" | 13 #include "base/lock.h" |
| 14 #include "base/singleton.h" | 14 #include "base/singleton.h" |
|
joth
2010/12/08 17:15:07
remove
| |
| 15 | 15 |
| 16 // CrossSiteRequestManager is used to handle bookkeeping for cross-site | 16 // CrossSiteRequestManager is used to handle bookkeeping for cross-site |
| 17 // requests and responses between the UI and IO threads. Such requests involve | 17 // requests and responses between the UI and IO threads. Such requests involve |
| 18 // a transition from one RenderViewHost to another within TabContents, and | 18 // a transition from one RenderViewHost to another within TabContents, and |
| 19 // involve coordination with ResourceDispatcherHost. | 19 // involve coordination with ResourceDispatcherHost. |
| 20 // | 20 // |
| 21 // CrossSiteRequestManager is a singleton that may be used on any thread. | 21 // CrossSiteRequestManager is a singleton that may be used on any thread. |
| 22 // | 22 // |
| 23 class CrossSiteRequestManager { | 23 class CrossSiteRequestManager { |
| 24 public: | 24 public: |
| 25 // Returns the singleton instance. | |
| 26 static CrossSiteRequestManager* GetInstance(); | |
| 27 | |
| 25 // Returns whether the RenderViewHost specified by the given IDs currently | 28 // Returns whether the RenderViewHost specified by the given IDs currently |
| 26 // has a pending cross-site request. If so, we will have to delay the | 29 // has a pending cross-site request. If so, we will have to delay the |
| 27 // response until the previous RenderViewHost runs its onunload handler. | 30 // response until the previous RenderViewHost runs its onunload handler. |
| 28 // Called by ResourceDispatcherHost on the IO thread. | 31 // Called by ResourceDispatcherHost on the IO thread. |
| 29 bool HasPendingCrossSiteRequest(int renderer_id, int render_view_id); | 32 bool HasPendingCrossSiteRequest(int renderer_id, int render_view_id); |
| 30 | 33 |
| 31 // Sets whether the RenderViewHost specified by the given IDs currently has a | 34 // Sets whether the RenderViewHost specified by the given IDs currently has a |
| 32 // pending cross-site request. Called by RenderViewHost on the UI thread. | 35 // pending cross-site request. Called by RenderViewHost on the UI thread. |
| 33 void SetHasPendingCrossSiteRequest(int renderer_id, | 36 void SetHasPendingCrossSiteRequest(int renderer_id, |
| 34 int render_view_id, | 37 int render_view_id, |
| 35 bool has_pending); | 38 bool has_pending); |
| 36 | 39 |
| 37 private: | 40 private: |
| 38 friend struct DefaultSingletonTraits<CrossSiteRequestManager>; | 41 friend struct DefaultSingletonTraits<CrossSiteRequestManager>; |
| 39 typedef std::set<std::pair<int, int> > RenderViewSet; | 42 typedef std::set<std::pair<int, int> > RenderViewSet; |
| 40 | 43 |
| 41 // Obtain an instance of CrossSiteRequestManager via | |
| 42 // Singleton<CrossSiteRequestManager>(). | |
| 43 CrossSiteRequestManager(); | 44 CrossSiteRequestManager(); |
| 44 ~CrossSiteRequestManager(); | 45 ~CrossSiteRequestManager(); |
| 45 | 46 |
| 46 // You must acquire this lock before reading or writing any members of this | 47 // You must acquire this lock before reading or writing any members of this |
| 47 // class. You must not block while holding this lock. | 48 // class. You must not block while holding this lock. |
| 48 Lock lock_; | 49 Lock lock_; |
| 49 | 50 |
| 50 // Set of (render_process_host_id, render_view_id) pairs of all | 51 // Set of (render_process_host_id, render_view_id) pairs of all |
| 51 // RenderViewHosts that have pending cross-site requests. Used to pass | 52 // RenderViewHosts that have pending cross-site requests. Used to pass |
| 52 // information about the RenderViewHosts between the UI and IO threads. | 53 // information about the RenderViewHosts between the UI and IO threads. |
| 53 RenderViewSet pending_cross_site_views_; | 54 RenderViewSet pending_cross_site_views_; |
| 54 | 55 |
| 55 DISALLOW_COPY_AND_ASSIGN(CrossSiteRequestManager); | 56 DISALLOW_COPY_AND_ASSIGN(CrossSiteRequestManager); |
| 56 }; | 57 }; |
| 57 | 58 |
| 58 #endif // CHROME_BROWSER_CROSS_SITE_REQUEST_MANAGER_H__ | 59 #endif // CHROME_BROWSER_CROSS_SITE_REQUEST_MANAGER_H__ |
| OLD | NEW |