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

Side by Side Diff: chrome/browser/cert_store.cc

Issue 6142009: Upating the app, ceee, chrome, ipc, media, and net directories to use the correct lock.h file. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Unified patch updating all references to the new base/synchronization/lock.h Created 9 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 | « chrome/browser/cert_store.h ('k') | chrome/browser/child_process_launcher.cc » ('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 (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 #include "chrome/browser/cert_store.h" 5 #include "chrome/browser/cert_store.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 9
10 #include "base/stl_util-inl.h" 10 #include "base/stl_util-inl.h"
(...skipping 28 matching lines...) Expand all
39 NotificationService::AllSources()); 39 NotificationService::AllSources());
40 registrar_.Add(this, NotificationType::RENDERER_PROCESS_CLOSED, 40 registrar_.Add(this, NotificationType::RENDERER_PROCESS_CLOSED,
41 NotificationService::AllSources()); 41 NotificationService::AllSources());
42 } 42 }
43 43
44 CertStore::~CertStore() { 44 CertStore::~CertStore() {
45 } 45 }
46 46
47 int CertStore::StoreCert(net::X509Certificate* cert, int process_id) { 47 int CertStore::StoreCert(net::X509Certificate* cert, int process_id) {
48 DCHECK(cert); 48 DCHECK(cert);
49 AutoLock autoLock(cert_lock_); 49 base::AutoLock autoLock(cert_lock_);
50 50
51 int cert_id; 51 int cert_id;
52 52
53 // Do we already know this cert? 53 // Do we already know this cert?
54 ReverseCertMap::iterator cert_iter = cert_to_id_.find(cert); 54 ReverseCertMap::iterator cert_iter = cert_to_id_.find(cert);
55 if (cert_iter == cert_to_id_.end()) { 55 if (cert_iter == cert_to_id_.end()) {
56 cert_id = next_cert_id_++; 56 cert_id = next_cert_id_++;
57 // We use 0 as an invalid cert_id value. In the unlikely event that 57 // We use 0 as an invalid cert_id value. In the unlikely event that
58 // next_cert_id_ wraps around, we reset it to 1. 58 // next_cert_id_ wraps around, we reset it to 1.
59 if (next_cert_id_ == 0) 59 if (next_cert_id_ == 0)
(...skipping 19 matching lines...) Expand all
79 MatchSecond<int>(process_id)) == 79 MatchSecond<int>(process_id)) ==
80 cert_id_to_process_id_.upper_bound(cert_id)) { 80 cert_id_to_process_id_.upper_bound(cert_id)) {
81 cert_id_to_process_id_.insert(std::make_pair(cert_id, process_id)); 81 cert_id_to_process_id_.insert(std::make_pair(cert_id, process_id));
82 } 82 }
83 83
84 return cert_id; 84 return cert_id;
85 } 85 }
86 86
87 bool CertStore::RetrieveCert(int cert_id, 87 bool CertStore::RetrieveCert(int cert_id,
88 scoped_refptr<net::X509Certificate>* cert) { 88 scoped_refptr<net::X509Certificate>* cert) {
89 AutoLock autoLock(cert_lock_); 89 base::AutoLock autoLock(cert_lock_);
90 90
91 CertMap::iterator iter = id_to_cert_.find(cert_id); 91 CertMap::iterator iter = id_to_cert_.find(cert_id);
92 if (iter == id_to_cert_.end()) 92 if (iter == id_to_cert_.end())
93 return false; 93 return false;
94 if (cert) 94 if (cert)
95 *cert = iter->second; 95 *cert = iter->second;
96 return true; 96 return true;
97 } 97 }
98 98
99 void CertStore::RemoveCertInternal(int cert_id) { 99 void CertStore::RemoveCertInternal(int cert_id) {
100 CertMap::iterator cert_iter = id_to_cert_.find(cert_id); 100 CertMap::iterator cert_iter = id_to_cert_.find(cert_id);
101 DCHECK(cert_iter != id_to_cert_.end()); 101 DCHECK(cert_iter != id_to_cert_.end());
102 102
103 ReverseCertMap::iterator id_iter = cert_to_id_.find(cert_iter->second); 103 ReverseCertMap::iterator id_iter = cert_to_id_.find(cert_iter->second);
104 DCHECK(id_iter != cert_to_id_.end()); 104 DCHECK(id_iter != cert_to_id_.end());
105 cert_to_id_.erase(id_iter); 105 cert_to_id_.erase(id_iter);
106 106
107 cert_iter->second->Release(); 107 cert_iter->second->Release();
108 id_to_cert_.erase(cert_iter); 108 id_to_cert_.erase(cert_iter);
109 } 109 }
110 110
111 void CertStore::RemoveCertsForRenderProcesHost(int process_id) { 111 void CertStore::RemoveCertsForRenderProcesHost(int process_id) {
112 AutoLock autoLock(cert_lock_); 112 base::AutoLock autoLock(cert_lock_);
113 113
114 // We iterate through all the cert ids for that process. 114 // We iterate through all the cert ids for that process.
115 IDMap::iterator ids_iter; 115 IDMap::iterator ids_iter;
116 for (ids_iter = process_id_to_cert_id_.lower_bound(process_id); 116 for (ids_iter = process_id_to_cert_id_.lower_bound(process_id);
117 ids_iter != process_id_to_cert_id_.upper_bound(process_id);) { 117 ids_iter != process_id_to_cert_id_.upper_bound(process_id);) {
118 int cert_id = ids_iter->second; 118 int cert_id = ids_iter->second;
119 // Remove this process from cert_id_to_process_id_. 119 // Remove this process from cert_id_to_process_id_.
120 IDMap::iterator proc_iter = 120 IDMap::iterator proc_iter =
121 std::find_if(cert_id_to_process_id_.lower_bound(cert_id), 121 std::find_if(cert_id_to_process_id_.lower_bound(cert_id),
122 cert_id_to_process_id_.upper_bound(cert_id), 122 cert_id_to_process_id_.upper_bound(cert_id),
(...skipping 14 matching lines...) Expand all
137 137
138 void CertStore::Observe(NotificationType type, 138 void CertStore::Observe(NotificationType type,
139 const NotificationSource& source, 139 const NotificationSource& source,
140 const NotificationDetails& details) { 140 const NotificationDetails& details) {
141 DCHECK(type == NotificationType::RENDERER_PROCESS_TERMINATED || 141 DCHECK(type == NotificationType::RENDERER_PROCESS_TERMINATED ||
142 type == NotificationType::RENDERER_PROCESS_CLOSED); 142 type == NotificationType::RENDERER_PROCESS_CLOSED);
143 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr(); 143 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr();
144 DCHECK(rph); 144 DCHECK(rph);
145 RemoveCertsForRenderProcesHost(rph->id()); 145 RemoveCertsForRenderProcesHost(rph->id());
146 } 146 }
OLDNEW
« no previous file with comments | « chrome/browser/cert_store.h ('k') | chrome/browser/child_process_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698