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

Side by Side Diff: extensions/browser/process_map.cc

Issue 139943005: Convert extensions::ProcessMap to BrowserContextKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase process_map Created 6 years, 11 months 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
« no previous file with comments | « extensions/browser/process_map.h ('k') | extensions/browser/process_map_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "extensions/browser/process_map.h" 5 #include "extensions/browser/process_map.h"
6 6
7 #include "extensions/browser/process_map_factory.h"
8
7 namespace extensions { 9 namespace extensions {
8 10
9 // Item 11 // Item
10 struct ProcessMap::Item { 12 struct ProcessMap::Item {
11 Item() : process_id(0), site_instance_id(0) { 13 Item() : process_id(0), site_instance_id(0) {
12 } 14 }
13 15
14 // Purposely implicit constructor needed on older gcc's. See: 16 // Purposely implicit constructor needed on older gcc's. See:
15 // http://codereview.chromium.org/8769022/ 17 // http://codereview.chromium.org/8769022/
16 explicit Item(const ProcessMap::Item& other) 18 explicit Item(const ProcessMap::Item& other)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 }; 55 };
54 56
55 57
56 // ProcessMap 58 // ProcessMap
57 ProcessMap::ProcessMap() { 59 ProcessMap::ProcessMap() {
58 } 60 }
59 61
60 ProcessMap::~ProcessMap() { 62 ProcessMap::~ProcessMap() {
61 } 63 }
62 64
65 // static
66 ProcessMap* ProcessMap::Get(content::BrowserContext* browser_context) {
67 return ProcessMapFactory::GetForBrowserContext(browser_context);
68 }
69
63 bool ProcessMap::Insert(const std::string& extension_id, int process_id, 70 bool ProcessMap::Insert(const std::string& extension_id, int process_id,
64 int site_instance_id) { 71 int site_instance_id) {
65 return items_.insert(Item(extension_id, process_id, site_instance_id)).second; 72 return items_.insert(Item(extension_id, process_id, site_instance_id)).second;
66 } 73 }
67 74
68 bool ProcessMap::Remove(const std::string& extension_id, int process_id, 75 bool ProcessMap::Remove(const std::string& extension_id, int process_id,
69 int site_instance_id) { 76 int site_instance_id) {
70 return items_.erase(Item(extension_id, process_id, site_instance_id)) > 0; 77 return items_.erase(Item(extension_id, process_id, site_instance_id)) > 0;
71 } 78 }
72 79
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 std::set<std::string> ProcessMap::GetExtensionsInProcess(int process_id) const { 112 std::set<std::string> ProcessMap::GetExtensionsInProcess(int process_id) const {
106 std::set<std::string> result; 113 std::set<std::string> result;
107 for (ItemSet::const_iterator iter = items_.begin(); iter != items_.end(); 114 for (ItemSet::const_iterator iter = items_.begin(); iter != items_.end();
108 ++iter) { 115 ++iter) {
109 if (iter->process_id == process_id) 116 if (iter->process_id == process_id)
110 result.insert(iter->extension_id); 117 result.insert(iter->extension_id);
111 } 118 }
112 return result; 119 return result;
113 } 120 }
114 121
115 } // extensions 122 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/process_map.h ('k') | extensions/browser/process_map_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698