Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / chrome / browser / extensions / extension_renderer_state.h
blob6aad734a019a3d7d19825f19fa80da376c9c0199
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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_RENDERER_STATE_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_RENDERER_STATE_H_
8 #include <map>
9 #include <set>
10 #include <string>
11 #include <utility>
13 #include "base/basictypes.h"
14 #include "base/memory/singleton.h"
16 namespace content {
17 class ResourceRequestInfo;
20 // This class keeps track of renderer state for use on the IO thread. All
21 // methods should be called on the IO thread except for Init and Shutdown.
22 class ExtensionRendererState {
23 public:
24 static ExtensionRendererState* GetInstance();
26 // These are called on the UI thread to start and stop listening to tab
27 // notifications.
28 void Init();
29 void Shutdown();
31 // Looks up the tab and window ID for a given request. Returns true if we have
32 // the IDs in our map. Called on the IO thread.
33 bool GetTabAndWindowId(
34 const content::ResourceRequestInfo* info, int* tab_id, int* window_id);
36 private:
37 class RenderViewHostObserver;
38 class TabObserver;
39 friend class TabObserver;
40 friend struct DefaultSingletonTraits<ExtensionRendererState>;
42 typedef std::pair<int, int> RenderId;
43 typedef std::pair<int, int> TabAndWindowId;
44 typedef std::map<RenderId, TabAndWindowId> TabAndWindowIdMap;
46 ExtensionRendererState();
47 ~ExtensionRendererState();
49 // Adds or removes a render view from our map.
50 void SetTabAndWindowId(
51 int render_process_host_id, int routing_id, int tab_id, int window_id);
52 void ClearTabAndWindowId(
53 int render_process_host_id, int routing_id);
55 TabObserver* observer_;
56 TabAndWindowIdMap map_;
58 DISALLOW_COPY_AND_ASSIGN(ExtensionRendererState);
61 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_RENDERER_STATE_H_