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

Side by Side Diff: webkit/tools/test_shell/test_geolocation_service.cc

Issue 3294007: Make delayed-permission-denied-for-multiple-requests pass (Closed)
Patch Set: Add expectation override Created 10 years, 3 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 | « webkit/tools/test_shell/test_geolocation_service.h ('k') | no next file » | 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 "webkit/tools/test_shell/test_geolocation_service.h" 5 #include "webkit/tools/test_shell/test_geolocation_service.h"
6 6
7 #include "third_party/WebKit/WebKit/chromium/public/WebGeolocationServiceBridge. h" 7 #include "third_party/WebKit/WebKit/chromium/public/WebGeolocationServiceBridge. h"
8 8
9 TestGeolocationService::TestGeolocationService() 9 TestGeolocationService::TestGeolocationService()
10 : allowed_(false) { 10 : allowed_(false),
11 permission_set_(false) {
11 } 12 }
12 13
13 TestGeolocationService::~TestGeolocationService() { 14 TestGeolocationService::~TestGeolocationService() {
14
15 } 15 }
16 16
17 void TestGeolocationService::SetGeolocationPermission(bool allowed) { 17 void TestGeolocationService::SetGeolocationPermission(bool allowed) {
18 allowed_ = allowed; 18 allowed_ = allowed;
19 permission_set_ = true;
20 TryToSendPermissions();
19 } 21 }
20 22
21 void TestGeolocationService::requestPermissionForFrame( 23 void TestGeolocationService::requestPermissionForFrame(
22 int bridgeId, const WebKit::WebURL& url) { 24 int bridgeId, const WebKit::WebURL& url) {
23 pending_permissions_.push_back(std::make_pair(bridgeId, allowed_)); 25 DCHECK(bridges_map_.Lookup(bridgeId)) << "Unknown bridge " << bridgeId;
24 permission_timer_.Start(base::TimeDelta::FromMilliseconds(0), 26 pending_permissions_.push_back(bridgeId);
25 this, &TestGeolocationService::SendPermission); 27 TryToSendPermissions();
26 } 28 }
27 29
28 int TestGeolocationService::attachBridge( 30 int TestGeolocationService::attachBridge(
29 WebKit::WebGeolocationServiceBridge* bridge) { 31 WebKit::WebGeolocationServiceBridge* bridge) {
30 return bridges_map_.Add(bridge); 32 return bridges_map_.Add(bridge);
31 } 33 }
32 34
33 void TestGeolocationService::detachBridge(int bridgeId) { 35 void TestGeolocationService::detachBridge(int bridgeId) {
34 bridges_map_.Remove(bridgeId); 36 bridges_map_.Remove(bridgeId);
37 std::vector<int>::iterator i = pending_permissions_.begin();
38 while (i != pending_permissions_.end()) {
39 if (*i == bridgeId)
40 pending_permissions_.erase(i);
41 else
42 ++i;
43 }
44 }
45
46 void TestGeolocationService::TryToSendPermissions() {
47 if (permission_set_ && !permission_timer_.IsRunning())
48 permission_timer_.Start(base::TimeDelta::FromMilliseconds(0),
49 this, &TestGeolocationService::SendPermission);
35 } 50 }
36 51
37 void TestGeolocationService::SendPermission() { 52 void TestGeolocationService::SendPermission() {
38 for (std::vector<std::pair<int, bool> >::const_iterator i = 53 DCHECK(permission_set_);
39 pending_permissions_.begin(); i != pending_permissions_.end(); ++i) { 54 std::vector<int> pending_permissions;
55 pending_permissions.swap(pending_permissions_);
56 for (std::vector<int>::const_iterator i = pending_permissions.begin();
57 i != pending_permissions.end(); ++i) {
40 WebKit::WebGeolocationServiceBridge* bridge = 58 WebKit::WebGeolocationServiceBridge* bridge =
41 bridges_map_.Lookup(i->first); 59 bridges_map_.Lookup(*i);
42 DCHECK(bridge); 60 DCHECK(bridge);
bulach 2010/09/06 11:51:48 not entirely sure why you're copying the vector, i
joth 2010/09/06 12:08:57 I'm not copying the vector, I'm swapping it (impor
43 bridge->setIsAllowed(i->second); 61 bridge->setIsAllowed(allowed_);
44 } 62 }
45 pending_permissions_.clear();
46 } 63 }
OLDNEW
« no previous file with comments | « webkit/tools/test_shell/test_geolocation_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698