OLD | NEW |
---|---|
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 28 matching lines...) Expand all Loading... | |
39 class WebGeolocationPermissionRequestManagerPrivate { | 39 class WebGeolocationPermissionRequestManagerPrivate { |
40 public: | 40 public: |
41 GeolocationIdMap m_geolocationIdMap; | 41 GeolocationIdMap m_geolocationIdMap; |
42 IdGeolocationMap m_idGeolocationMap; | 42 IdGeolocationMap m_idGeolocationMap; |
43 }; | 43 }; |
44 | 44 |
45 int WebGeolocationPermissionRequestManager::add(const blink::WebGeolocationPermi ssionRequest& permissionRequest) | 45 int WebGeolocationPermissionRequestManager::add(const blink::WebGeolocationPermi ssionRequest& permissionRequest) |
46 { | 46 { |
47 Geolocation* geolocation = permissionRequest.geolocation(); | 47 Geolocation* geolocation = permissionRequest.geolocation(); |
48 ASSERT(!m_private->m_geolocationIdMap.contains(geolocation)); | 48 ASSERT(!m_private->m_geolocationIdMap.contains(geolocation)); |
49 int id = ++m_lastId; | 49 static int lastId; |
dglazkov
2014/05/30 18:31:42
Ideally, there's a static function that vends ids.
| |
50 int id = ++lastId; | |
50 m_private->m_geolocationIdMap.add(geolocation, id); | 51 m_private->m_geolocationIdMap.add(geolocation, id); |
51 m_private->m_idGeolocationMap.add(id, geolocation); | 52 m_private->m_idGeolocationMap.add(id, geolocation); |
52 return id; | 53 return id; |
53 } | 54 } |
54 | 55 |
55 bool WebGeolocationPermissionRequestManager::remove(const blink::WebGeolocationP ermissionRequest& permissionRequest, int& id) | 56 bool WebGeolocationPermissionRequestManager::remove(const blink::WebGeolocationP ermissionRequest& permissionRequest, int& id) |
56 { | 57 { |
57 Geolocation* geolocation = permissionRequest.geolocation(); | 58 Geolocation* geolocation = permissionRequest.geolocation(); |
58 GeolocationIdMap::iterator it = m_private->m_geolocationIdMap.find(geolocati on); | 59 GeolocationIdMap::iterator it = m_private->m_geolocationIdMap.find(geolocati on); |
59 if (it == m_private->m_geolocationIdMap.end()) | 60 if (it == m_private->m_geolocationIdMap.end()) |
(...skipping 11 matching lines...) Expand all Loading... | |
71 return false; | 72 return false; |
72 Geolocation* geolocation = it->value; | 73 Geolocation* geolocation = it->value; |
73 permissionRequest = WebGeolocationPermissionRequest(geolocation); | 74 permissionRequest = WebGeolocationPermissionRequest(geolocation); |
74 m_private->m_idGeolocationMap.remove(it); | 75 m_private->m_idGeolocationMap.remove(it); |
75 m_private->m_geolocationIdMap.remove(geolocation); | 76 m_private->m_geolocationIdMap.remove(geolocation); |
76 return true; | 77 return true; |
77 } | 78 } |
78 | 79 |
79 void WebGeolocationPermissionRequestManager::init() | 80 void WebGeolocationPermissionRequestManager::init() |
80 { | 81 { |
81 m_lastId = 0; | |
82 m_private.reset(new WebGeolocationPermissionRequestManagerPrivate); | 82 m_private.reset(new WebGeolocationPermissionRequestManagerPrivate); |
83 } | 83 } |
84 | 84 |
85 void WebGeolocationPermissionRequestManager::reset() | 85 void WebGeolocationPermissionRequestManager::reset() |
86 { | 86 { |
87 m_private.reset(0); | 87 m_private.reset(0); |
88 } | 88 } |
89 | 89 |
90 } // namespace blink | 90 } // namespace blink |
OLD | NEW |