OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/intents/web_intents_registry.h" | 5 #include "chrome/browser/intents/web_intents_registry.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 public: | 168 public: |
169 // Underlying data query. | 169 // Underlying data query. |
170 WebDataService::Handle query_handle_; | 170 WebDataService::Handle query_handle_; |
171 | 171 |
172 // Create a new QueryAdapter that delegates results to |handler|. | 172 // Create a new QueryAdapter that delegates results to |handler|. |
173 QueryAdapter(WebIntentsRegistry* registry, const ResultsHandler& handler) | 173 QueryAdapter(WebIntentsRegistry* registry, const ResultsHandler& handler) |
174 : registry_(registry), handler_(handler) { | 174 : registry_(registry), handler_(handler) { |
175 registry_->TrackQuery(this); | 175 registry_->TrackQuery(this); |
176 } | 176 } |
177 | 177 |
178 void OnWebDataServiceRequestDone( | 178 virtual void OnWebDataServiceRequestDone( |
179 WebDataService::Handle h, | 179 WebDataService::Handle h, |
180 const WDTypedResult* result) OVERRIDE { | 180 const WDTypedResult* result) OVERRIDE { |
181 | 181 |
182 handler_.Run(result); | 182 handler_.Run(result); |
183 registry_->ReleaseQuery(this); | 183 registry_->ReleaseQuery(this); |
184 } | 184 } |
185 | 185 |
186 private: | 186 private: |
187 // Handle so we can call back into the WebIntentsRegistry when | 187 // Handle so we can call back into the WebIntentsRegistry when |
188 // processing query results. The registry is guaranteed to be | 188 // processing query results. The registry is guaranteed to be |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 void WebIntentsRegistry::ReleaseQuery(QueryAdapter* query) { | 519 void WebIntentsRegistry::ReleaseQuery(QueryAdapter* query) { |
520 QueryVector::iterator it = std::find( | 520 QueryVector::iterator it = std::find( |
521 pending_queries_.begin(), pending_queries_.end(), query); | 521 pending_queries_.begin(), pending_queries_.end(), query); |
522 if (it != pending_queries_.end()) { | 522 if (it != pending_queries_.end()) { |
523 pending_queries_.erase(it); | 523 pending_queries_.erase(it); |
524 delete query; | 524 delete query; |
525 } else { | 525 } else { |
526 NOTREACHED(); | 526 NOTREACHED(); |
527 } | 527 } |
528 } | 528 } |
OLD | NEW |