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

Side by Side Diff: Source/web/WebGeolocationPermissionRequestManager.cpp

Issue 468083003: Cleanup namespace usage in Source/web/Web[A-H]*.cpp (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebasing Created 6 years, 4 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
« no previous file with comments | « Source/web/WebGeolocationPermissionRequest.cpp ('k') | Source/web/WebGeolocationPosition.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 12 matching lines...) Expand all
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "public/web/WebGeolocationPermissionRequestManager.h" 27 #include "public/web/WebGeolocationPermissionRequestManager.h"
28 28
29 #include "modules/geolocation/Geolocation.h" 29 #include "modules/geolocation/Geolocation.h"
30 #include "public/web/WebGeolocationPermissionRequest.h" 30 #include "public/web/WebGeolocationPermissionRequest.h"
31 #include "wtf/HashMap.h" 31 #include "wtf/HashMap.h"
32 32
33 using namespace blink;
34
35 namespace blink { 33 namespace blink {
36 34
37 typedef PersistentHeapHashMap<Member<Geolocation>, int> GeolocationIdMap; 35 typedef PersistentHeapHashMap<Member<Geolocation>, int> GeolocationIdMap;
38 typedef PersistentHeapHashMap<int, Member<Geolocation> > IdGeolocationMap; 36 typedef PersistentHeapHashMap<int, Member<Geolocation> > IdGeolocationMap;
39 37
40 class WebGeolocationPermissionRequestManagerPrivate { 38 class WebGeolocationPermissionRequestManagerPrivate {
41 public: 39 public:
42 GeolocationIdMap m_geolocationIdMap; 40 GeolocationIdMap m_geolocationIdMap;
43 IdGeolocationMap m_idGeolocationMap; 41 IdGeolocationMap m_idGeolocationMap;
44 }; 42 };
45 43
46 int WebGeolocationPermissionRequestManager::add(const blink::WebGeolocationPermi ssionRequest& permissionRequest) 44 int WebGeolocationPermissionRequestManager::add(const WebGeolocationPermissionRe quest& permissionRequest)
47 { 45 {
48 Geolocation* geolocation = permissionRequest.geolocation(); 46 Geolocation* geolocation = permissionRequest.geolocation();
49 ASSERT(!m_private->m_geolocationIdMap.contains(geolocation)); 47 ASSERT(!m_private->m_geolocationIdMap.contains(geolocation));
50 static int lastId; 48 static int lastId;
51 int id = ++lastId; 49 int id = ++lastId;
52 m_private->m_geolocationIdMap.add(geolocation, id); 50 m_private->m_geolocationIdMap.add(geolocation, id);
53 m_private->m_idGeolocationMap.add(id, geolocation); 51 m_private->m_idGeolocationMap.add(id, geolocation);
54 return id; 52 return id;
55 } 53 }
56 54
57 bool WebGeolocationPermissionRequestManager::remove(const blink::WebGeolocationP ermissionRequest& permissionRequest, int& id) 55 bool WebGeolocationPermissionRequestManager::remove(const WebGeolocationPermissi onRequest& permissionRequest, int& id)
58 { 56 {
59 Geolocation* geolocation = permissionRequest.geolocation(); 57 Geolocation* geolocation = permissionRequest.geolocation();
60 GeolocationIdMap::iterator it = m_private->m_geolocationIdMap.find(geolocati on); 58 GeolocationIdMap::iterator it = m_private->m_geolocationIdMap.find(geolocati on);
61 if (it == m_private->m_geolocationIdMap.end()) 59 if (it == m_private->m_geolocationIdMap.end())
62 return false; 60 return false;
63 id = it->value; 61 id = it->value;
64 m_private->m_geolocationIdMap.remove(it); 62 m_private->m_geolocationIdMap.remove(it);
65 m_private->m_idGeolocationMap.remove(id); 63 m_private->m_idGeolocationMap.remove(id);
66 return true; 64 return true;
67 } 65 }
68 66
69 bool WebGeolocationPermissionRequestManager::remove(int id, blink::WebGeolocatio nPermissionRequest& permissionRequest) 67 bool WebGeolocationPermissionRequestManager::remove(int id, WebGeolocationPermis sionRequest& permissionRequest)
70 { 68 {
71 IdGeolocationMap::iterator it = m_private->m_idGeolocationMap.find(id); 69 IdGeolocationMap::iterator it = m_private->m_idGeolocationMap.find(id);
72 if (it == m_private->m_idGeolocationMap.end()) 70 if (it == m_private->m_idGeolocationMap.end())
73 return false; 71 return false;
74 Geolocation* geolocation = it->value; 72 Geolocation* geolocation = it->value;
75 permissionRequest = WebGeolocationPermissionRequest(geolocation); 73 permissionRequest = WebGeolocationPermissionRequest(geolocation);
76 m_private->m_idGeolocationMap.remove(it); 74 m_private->m_idGeolocationMap.remove(it);
77 m_private->m_geolocationIdMap.remove(geolocation); 75 m_private->m_geolocationIdMap.remove(geolocation);
78 return true; 76 return true;
79 } 77 }
80 78
81 void WebGeolocationPermissionRequestManager::init() 79 void WebGeolocationPermissionRequestManager::init()
82 { 80 {
83 m_private.reset(new WebGeolocationPermissionRequestManagerPrivate); 81 m_private.reset(new WebGeolocationPermissionRequestManagerPrivate);
84 } 82 }
85 83
86 void WebGeolocationPermissionRequestManager::reset() 84 void WebGeolocationPermissionRequestManager::reset()
87 { 85 {
88 m_private.reset(0); 86 m_private.reset(0);
89 } 87 }
90 88
91 } // namespace blink 89 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebGeolocationPermissionRequest.cpp ('k') | Source/web/WebGeolocationPosition.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698