Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Side by Side Diff: chrome/browser/cross_site_request_manager.h

Issue 5519016: Add a new GetInstance() method for singleton classes used in chrome/browser files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
15 template <typename T> struct DefaultSingletonTraits;
15 16
16 // CrossSiteRequestManager is used to handle bookkeeping for cross-site 17 // CrossSiteRequestManager is used to handle bookkeeping for cross-site
17 // requests and responses between the UI and IO threads. Such requests involve 18 // requests and responses between the UI and IO threads. Such requests involve
18 // a transition from one RenderViewHost to another within TabContents, and 19 // a transition from one RenderViewHost to another within TabContents, and
19 // involve coordination with ResourceDispatcherHost. 20 // involve coordination with ResourceDispatcherHost.
20 // 21 //
21 // CrossSiteRequestManager is a singleton that may be used on any thread. 22 // CrossSiteRequestManager is a singleton that may be used on any thread.
22 // 23 //
23 class CrossSiteRequestManager { 24 class CrossSiteRequestManager {
24 public: 25 public:
26 // Returns the singleton instance.
27 static CrossSiteRequestManager* GetInstance();
28
25 // Returns whether the RenderViewHost specified by the given IDs currently 29 // 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 30 // has a pending cross-site request. If so, we will have to delay the
27 // response until the previous RenderViewHost runs its onunload handler. 31 // response until the previous RenderViewHost runs its onunload handler.
28 // Called by ResourceDispatcherHost on the IO thread. 32 // Called by ResourceDispatcherHost on the IO thread.
29 bool HasPendingCrossSiteRequest(int renderer_id, int render_view_id); 33 bool HasPendingCrossSiteRequest(int renderer_id, int render_view_id);
30 34
31 // Sets whether the RenderViewHost specified by the given IDs currently has a 35 // Sets whether the RenderViewHost specified by the given IDs currently has a
32 // pending cross-site request. Called by RenderViewHost on the UI thread. 36 // pending cross-site request. Called by RenderViewHost on the UI thread.
33 void SetHasPendingCrossSiteRequest(int renderer_id, 37 void SetHasPendingCrossSiteRequest(int renderer_id,
34 int render_view_id, 38 int render_view_id,
35 bool has_pending); 39 bool has_pending);
36 40
37 private: 41 private:
38 friend struct DefaultSingletonTraits<CrossSiteRequestManager>; 42 friend struct DefaultSingletonTraits<CrossSiteRequestManager>;
39 typedef std::set<std::pair<int, int> > RenderViewSet; 43 typedef std::set<std::pair<int, int> > RenderViewSet;
40 44
41 // Obtain an instance of CrossSiteRequestManager via
42 // Singleton<CrossSiteRequestManager>().
43 CrossSiteRequestManager(); 45 CrossSiteRequestManager();
44 ~CrossSiteRequestManager(); 46 ~CrossSiteRequestManager();
45 47
46 // You must acquire this lock before reading or writing any members of this 48 // You must acquire this lock before reading or writing any members of this
47 // class. You must not block while holding this lock. 49 // class. You must not block while holding this lock.
48 Lock lock_; 50 Lock lock_;
49 51
50 // Set of (render_process_host_id, render_view_id) pairs of all 52 // Set of (render_process_host_id, render_view_id) pairs of all
51 // RenderViewHosts that have pending cross-site requests. Used to pass 53 // RenderViewHosts that have pending cross-site requests. Used to pass
52 // information about the RenderViewHosts between the UI and IO threads. 54 // information about the RenderViewHosts between the UI and IO threads.
53 RenderViewSet pending_cross_site_views_; 55 RenderViewSet pending_cross_site_views_;
54 56
55 DISALLOW_COPY_AND_ASSIGN(CrossSiteRequestManager); 57 DISALLOW_COPY_AND_ASSIGN(CrossSiteRequestManager);
56 }; 58 };
57 59
58 #endif // CHROME_BROWSER_CROSS_SITE_REQUEST_MANAGER_H__ 60 #endif // CHROME_BROWSER_CROSS_SITE_REQUEST_MANAGER_H__
OLDNEW
« no previous file with comments | « chrome/browser/crash_handler_host_linux_stub.cc ('k') | chrome/browser/cross_site_request_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698