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

Side by Side Diff: content/browser/cancelable_request.cc

Issue 6994005: Fix password automation hooks to get pyauto test testSavePassword working. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disabling a single pyauto passwords test. Created 9 years, 7 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/browser/cancelable_request.h" 5 #include "content/browser/cancelable_request.h"
6 6
7 CancelableRequestProvider::CancelableRequestProvider() 7 CancelableRequestProvider::CancelableRequestProvider()
8 : next_handle_(1) { 8 : next_handle_(1) {
9 } 9 }
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 void CancelableRequestProvider::CancelRequestLocked( 47 void CancelableRequestProvider::CancelRequestLocked(
48 const CancelableRequestMap::iterator& item) { 48 const CancelableRequestMap::iterator& item) {
49 pending_request_lock_.AssertAcquired(); 49 pending_request_lock_.AssertAcquired();
50 if (item == pending_requests_.end()) { 50 if (item == pending_requests_.end()) {
51 NOTREACHED() << "Trying to cancel an unknown request"; 51 NOTREACHED() << "Trying to cancel an unknown request";
52 return; 52 return;
53 } 53 }
54 54
55 item->second->consumer()->OnRequestRemoved(this, item->first); 55 item->second->consumer()->OnRequestRemoved(this, item->first);
56 item->second->set_canceled(); 56 item->second->set_canceled();
57 completed_requests_[item->first] = pending_requests_[item->first];
57 pending_requests_.erase(item); 58 pending_requests_.erase(item);
58 } 59 }
59 60
60 void CancelableRequestProvider::RequestCompleted(Handle handle) { 61 void CancelableRequestProvider::RequestCompleted(Handle handle) {
61 CancelableRequestConsumerBase* consumer = NULL; 62 CancelableRequestConsumerBase* consumer = NULL;
62 { 63 {
63 base::AutoLock lock(pending_request_lock_); 64 base::AutoLock lock(pending_request_lock_);
64 65
65 CancelableRequestMap::iterator i = pending_requests_.find(handle); 66 CancelableRequestMap::iterator i = pending_requests_.find(handle);
66 if (i == pending_requests_.end()) { 67 if (i == pending_requests_.end()) {
67 NOTREACHED() << "Trying to cancel an unknown request"; 68 NOTREACHED() << "Trying to cancel an unknown request";
68 return; 69 return;
69 } 70 }
70 consumer = i->second->consumer(); 71 consumer = i->second->consumer();
71 72
72 // This message should only get sent if the class is not cancelled, or 73 // This message should only get sent if the class is not cancelled, or
73 // else the consumer might be gone). 74 // else the consumer might be gone).
74 DCHECK(!i->second->canceled()); 75 DCHECK(!i->second->canceled());
75 76
77 completed_requests_[i->first] = pending_requests_[i->first];
76 pending_requests_.erase(i); 78 pending_requests_.erase(i);
77 } 79 }
78 80
79 // Notify the consumer that the request is gone 81 // Notify the consumer that the request is gone
80 consumer->OnRequestRemoved(this, handle); 82 consumer->OnRequestRemoved(this, handle);
81 } 83 }
82 84
85 bool CancelableRequestProvider::IsRequestCompleted(Handle handle) {
86 CancelableRequestMap::iterator i = completed_requests_.find(handle);
87 return i != completed_requests_.end();
88 }
89
83 // MSVC doesn't like complex extern templates and DLLs. 90 // MSVC doesn't like complex extern templates and DLLs.
84 #if !defined(COMPILER_MSVC) 91 #if !defined(COMPILER_MSVC)
85 // Emit our most common CancelableRequestConsumer. 92 // Emit our most common CancelableRequestConsumer.
86 template class CancelableRequestConsumerTSimple<int>; 93 template class CancelableRequestConsumerTSimple<int>;
87 94
88 // And the most common subclass of it. 95 // And the most common subclass of it.
89 template class CancelableRequestConsumerT<int, 0>; 96 template class CancelableRequestConsumerT<int, 0>;
90 #endif 97 #endif
91 98
92 CancelableRequestBase::CancelableRequestBase() 99 CancelableRequestBase::CancelableRequestBase()
93 : provider_(NULL), 100 : provider_(NULL),
94 consumer_(NULL), 101 consumer_(NULL),
95 handle_(0) { 102 handle_(0) {
96 callback_thread_ = MessageLoop::current(); 103 callback_thread_ = MessageLoop::current();
97 } 104 }
98 105
99 CancelableRequestBase::~CancelableRequestBase() { 106 CancelableRequestBase::~CancelableRequestBase() {
100 } 107 }
101 108
102 void CancelableRequestBase::Init(CancelableRequestProvider* provider, 109 void CancelableRequestBase::Init(CancelableRequestProvider* provider,
103 CancelableRequestProvider::Handle handle, 110 CancelableRequestProvider::Handle handle,
104 CancelableRequestConsumerBase* consumer) { 111 CancelableRequestConsumerBase* consumer) {
105 DCHECK(handle_ == 0 && provider_ == NULL && consumer_ == NULL); 112 DCHECK(handle_ == 0 && provider_ == NULL && consumer_ == NULL);
106 provider_ = provider; 113 provider_ = provider;
107 consumer_ = consumer; 114 consumer_ = consumer;
108 handle_ = handle; 115 handle_ = handle;
109 } 116 }
OLDNEW
« chrome/test/functional/passwords.py ('K') | « content/browser/cancelable_request.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698