| OLD | NEW |
| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 base::AutoLock l(cancel_lock_); | 57 base::AutoLock l(cancel_lock_); |
| 58 cancelled_ = true; | 58 cancelled_ = true; |
| 59 consumer_ = NULL; | 59 consumer_ = NULL; |
| 60 manager_ = NULL; | 60 manager_ = NULL; |
| 61 } | 61 } |
| 62 | 62 |
| 63 void WebDataRequest::OnComplete() { | 63 void WebDataRequest::OnComplete() { |
| 64 manager_= NULL; | 64 manager_= NULL; |
| 65 } | 65 } |
| 66 | 66 |
| 67 void WebDataRequest::SetResult(scoped_ptr<WDTypedResult> r) { | 67 void WebDataRequest::SetResult(std::unique_ptr<WDTypedResult> r) { |
| 68 result_ = std::move(r); | 68 result_ = std::move(r); |
| 69 } | 69 } |
| 70 | 70 |
| 71 scoped_ptr<WDTypedResult> WebDataRequest::GetResult(){ | 71 std::unique_ptr<WDTypedResult> WebDataRequest::GetResult() { |
| 72 return std::move(result_); | 72 return std::move(result_); |
| 73 } | 73 } |
| 74 | 74 |
| 75 //////////////////////////////////////////////////////////////////////////////// | 75 //////////////////////////////////////////////////////////////////////////////// |
| 76 // | 76 // |
| 77 // WebDataRequestManager implementation. | 77 // WebDataRequestManager implementation. |
| 78 // | 78 // |
| 79 //////////////////////////////////////////////////////////////////////////////// | 79 //////////////////////////////////////////////////////////////////////////////// |
| 80 | 80 |
| 81 WebDataRequestManager::WebDataRequestManager() | 81 WebDataRequestManager::WebDataRequestManager() |
| (...skipping 24 matching lines...) Expand all Loading... |
| 106 RequestMap::iterator i = pending_requests_.find(h); | 106 RequestMap::iterator i = pending_requests_.find(h); |
| 107 if (i == pending_requests_.end()) { | 107 if (i == pending_requests_.end()) { |
| 108 NOTREACHED() << "Canceling a nonexistent web data service request"; | 108 NOTREACHED() << "Canceling a nonexistent web data service request"; |
| 109 return; | 109 return; |
| 110 } | 110 } |
| 111 i->second->Cancel(); | 111 i->second->Cancel(); |
| 112 pending_requests_.erase(i); | 112 pending_requests_.erase(i); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void WebDataRequestManager::RequestCompleted( | 115 void WebDataRequestManager::RequestCompleted( |
| 116 scoped_ptr<WebDataRequest> request) { | 116 std::unique_ptr<WebDataRequest> request) { |
| 117 base::MessageLoop* loop = request->GetMessageLoop(); | 117 base::MessageLoop* loop = request->GetMessageLoop(); |
| 118 loop->task_runner()->PostTask( | 118 loop->task_runner()->PostTask( |
| 119 FROM_HERE, base::Bind(&WebDataRequestManager::RequestCompletedOnThread, | 119 FROM_HERE, base::Bind(&WebDataRequestManager::RequestCompletedOnThread, |
| 120 this, base::Passed(&request))); | 120 this, base::Passed(&request))); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void WebDataRequestManager::RequestCompletedOnThread( | 123 void WebDataRequestManager::RequestCompletedOnThread( |
| 124 scoped_ptr<WebDataRequest> request) { | 124 std::unique_ptr<WebDataRequest> request) { |
| 125 if (request->IsCancelled()) | 125 if (request->IsCancelled()) |
| 126 return; | 126 return; |
| 127 | 127 |
| 128 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is | 128 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is |
| 129 // fixed. | 129 // fixed. |
| 130 tracked_objects::ScopedTracker tracking_profile1( | 130 tracked_objects::ScopedTracker tracking_profile1( |
| 131 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 131 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 132 "422460 WebDataRequestManager::RequestCompletedOnThread::UpdateMap")); | 132 "422460 WebDataRequestManager::RequestCompletedOnThread::UpdateMap")); |
| 133 { | 133 { |
| 134 base::AutoLock l(pending_lock_); | 134 base::AutoLock l(pending_lock_); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 147 tracked_objects::ScopedTracker tracking_profile2( | 147 tracked_objects::ScopedTracker tracking_profile2( |
| 148 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 148 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 149 "422460 " | 149 "422460 " |
| 150 "WebDataRequestManager::RequestCompletedOnThread::NotifyConsumer")); | 150 "WebDataRequestManager::RequestCompletedOnThread::NotifyConsumer")); |
| 151 | 151 |
| 152 // Notify the consumer if needed. | 152 // Notify the consumer if needed. |
| 153 if (!request->IsCancelled()) { | 153 if (!request->IsCancelled()) { |
| 154 WebDataServiceConsumer* consumer = request->GetConsumer(); | 154 WebDataServiceConsumer* consumer = request->GetConsumer(); |
| 155 request->OnComplete(); | 155 request->OnComplete(); |
| 156 if (consumer) { | 156 if (consumer) { |
| 157 scoped_ptr<WDTypedResult> r = request->GetResult(); | 157 std::unique_ptr<WDTypedResult> r = request->GetResult(); |
| 158 consumer->OnWebDataServiceRequestDone(request->GetHandle(), r.get()); | 158 consumer->OnWebDataServiceRequestDone(request->GetHandle(), r.get()); |
| 159 } | 159 } |
| 160 } | 160 } |
| 161 | 161 |
| 162 } | 162 } |
| OLD | NEW |