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

Side by Side Diff: components/webdata/common/web_data_request_manager.cc

Issue 2422323002: Don't handle DCHECK failure. (Closed)
Patch Set: Created 4 years, 2 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 | « no previous file | 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "components/webdata/common/web_data_request_manager.h" 5 #include "components/webdata/common/web_data_request_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 97 }
98 98
99 int WebDataRequestManager::GetNextRequestHandle() { 99 int WebDataRequestManager::GetNextRequestHandle() {
100 base::AutoLock l(pending_lock_); 100 base::AutoLock l(pending_lock_);
101 return ++next_request_handle_; 101 return ++next_request_handle_;
102 } 102 }
103 103
104 void WebDataRequestManager::CancelRequest(WebDataServiceBase::Handle h) { 104 void WebDataRequestManager::CancelRequest(WebDataServiceBase::Handle h) {
105 base::AutoLock l(pending_lock_); 105 base::AutoLock l(pending_lock_);
106 RequestMap::iterator i = pending_requests_.find(h); 106 RequestMap::iterator i = pending_requests_.find(h);
107 if (i == pending_requests_.end()) { 107 DCHECK(i != pending_requests_.end());
108 NOTREACHED() << "Canceling a nonexistent web data service request";
109 return;
110 }
111 i->second->Cancel(); 108 i->second->Cancel();
112 pending_requests_.erase(i); 109 pending_requests_.erase(i);
113 } 110 }
114 111
115 void WebDataRequestManager::RequestCompleted( 112 void WebDataRequestManager::RequestCompleted(
116 std::unique_ptr<WebDataRequest> request) { 113 std::unique_ptr<WebDataRequest> request) {
117 scoped_refptr<base::SingleThreadTaskRunner> task_runner = 114 scoped_refptr<base::SingleThreadTaskRunner> task_runner =
118 request->GetTaskRunner(); 115 request->GetTaskRunner();
119 task_runner->PostTask( 116 task_runner->PostTask(
120 FROM_HERE, base::Bind(&WebDataRequestManager::RequestCompletedOnThread, 117 FROM_HERE, base::Bind(&WebDataRequestManager::RequestCompletedOnThread,
121 this, base::Passed(&request))); 118 this, base::Passed(&request)));
122 } 119 }
123 120
124 void WebDataRequestManager::RequestCompletedOnThread( 121 void WebDataRequestManager::RequestCompletedOnThread(
125 std::unique_ptr<WebDataRequest> request) { 122 std::unique_ptr<WebDataRequest> request) {
126 if (request->IsCancelled()) 123 if (request->IsCancelled())
127 return; 124 return;
128 125
129 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is 126 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is
130 // fixed. 127 // fixed.
131 tracked_objects::ScopedTracker tracking_profile1( 128 tracked_objects::ScopedTracker tracking_profile1(
132 FROM_HERE_WITH_EXPLICIT_FUNCTION( 129 FROM_HERE_WITH_EXPLICIT_FUNCTION(
133 "422460 WebDataRequestManager::RequestCompletedOnThread::UpdateMap")); 130 "422460 WebDataRequestManager::RequestCompletedOnThread::UpdateMap"));
134 { 131 {
135 base::AutoLock l(pending_lock_); 132 base::AutoLock l(pending_lock_);
136 RequestMap::iterator i = pending_requests_.find(request->GetHandle()); 133 RequestMap::iterator i = pending_requests_.find(request->GetHandle());
137 if (i == pending_requests_.end()) { 134 DCHECK(i != pending_requests_.end());
138 NOTREACHED() << "Request completed called for an unknown request";
139 return;
140 }
141 135
142 // Take ownership of the request object and remove it from the map. 136 // Take ownership of the request object and remove it from the map.
143 pending_requests_.erase(i); 137 pending_requests_.erase(i);
144 } 138 }
145 139
146 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is 140 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is
147 // fixed. 141 // fixed.
148 tracked_objects::ScopedTracker tracking_profile2( 142 tracked_objects::ScopedTracker tracking_profile2(
149 FROM_HERE_WITH_EXPLICIT_FUNCTION( 143 FROM_HERE_WITH_EXPLICIT_FUNCTION(
150 "422460 " 144 "422460 "
151 "WebDataRequestManager::RequestCompletedOnThread::NotifyConsumer")); 145 "WebDataRequestManager::RequestCompletedOnThread::NotifyConsumer"));
152 146
153 // Notify the consumer if needed. 147 // Notify the consumer if needed.
154 if (!request->IsCancelled()) { 148 if (!request->IsCancelled()) {
155 WebDataServiceConsumer* consumer = request->GetConsumer(); 149 WebDataServiceConsumer* consumer = request->GetConsumer();
156 request->OnComplete(); 150 request->OnComplete();
157 if (consumer) { 151 if (consumer) {
158 std::unique_ptr<WDTypedResult> r = request->GetResult(); 152 std::unique_ptr<WDTypedResult> r = request->GetResult();
159 consumer->OnWebDataServiceRequestDone(request->GetHandle(), r.get()); 153 consumer->OnWebDataServiceRequestDone(request->GetHandle(), r.get());
160 } 154 }
161 } 155 }
162 156
163 } 157 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698