| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/webdata/web_data_service.h" | 5 #include "chrome/browser/webdata/web_data_service.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "chrome/browser/search_engines/template_url.h" | 10 #include "chrome/browser/search_engines/template_url.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 ScheduleTask( | 132 ScheduleTask( |
| 133 NewRunnableMethod(this, | 133 NewRunnableMethod(this, |
| 134 &WebDataService::GetFormValuesForElementNameImpl, | 134 &WebDataService::GetFormValuesForElementNameImpl, |
| 135 request, | 135 request, |
| 136 name, | 136 name, |
| 137 prefix, | 137 prefix, |
| 138 limit)); | 138 limit)); |
| 139 return request->GetHandle(); | 139 return request->GetHandle(); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void WebDataService::RemoveFormValueForElementName( |
| 143 const std::wstring& name, const std::wstring& value) { |
| 144 GenericRequest2<std::wstring, std::wstring>* request = |
| 145 new GenericRequest2<std::wstring, std::wstring>(this, |
| 146 GetNextRequestHandle(), |
| 147 NULL, |
| 148 name, value); |
| 149 RegisterRequest(request); |
| 150 ScheduleTask( |
| 151 NewRunnableMethod(this, |
| 152 &WebDataService::RemoveFormValueForElementNameImpl, |
| 153 request)); |
| 154 } |
| 155 |
| 142 void WebDataService::RequestCompleted(Handle h) { | 156 void WebDataService::RequestCompleted(Handle h) { |
| 143 pending_lock_.Acquire(); | 157 pending_lock_.Acquire(); |
| 144 RequestMap::iterator i = pending_requests_.find(h); | 158 RequestMap::iterator i = pending_requests_.find(h); |
| 145 if (i == pending_requests_.end()) { | 159 if (i == pending_requests_.end()) { |
| 146 NOTREACHED() << "Request completed called for an unknown request"; | 160 NOTREACHED() << "Request completed called for an unknown request"; |
| 147 pending_lock_.Release(); | 161 pending_lock_.Release(); |
| 148 return; | 162 return; |
| 149 } | 163 } |
| 150 | 164 |
| 151 // Take ownership of the request object and remove it from the map. | 165 // Take ownership of the request object and remove it from the map. |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 void WebDataService::RemoveFormElementsAddedBetweenImpl( | 584 void WebDataService::RemoveFormElementsAddedBetweenImpl( |
| 571 GenericRequest2<Time, Time>* request) { | 585 GenericRequest2<Time, Time>* request) { |
| 572 if (db_ && !request->IsCancelled()) { | 586 if (db_ && !request->IsCancelled()) { |
| 573 if (db_->RemoveFormElementsAddedBetween(request->GetArgument1(), | 587 if (db_->RemoveFormElementsAddedBetween(request->GetArgument1(), |
| 574 request->GetArgument2())) | 588 request->GetArgument2())) |
| 575 ScheduleCommit(); | 589 ScheduleCommit(); |
| 576 } | 590 } |
| 577 request->RequestComplete(); | 591 request->RequestComplete(); |
| 578 } | 592 } |
| 579 | 593 |
| 594 void WebDataService::RemoveFormValueForElementNameImpl( |
| 595 GenericRequest2<std::wstring, std::wstring>* request) { |
| 596 if (db_ && !request->IsCancelled()) { |
| 597 if (db_->RemoveFormElement(request->GetArgument1(), |
| 598 request->GetArgument2())) |
| 599 ScheduleCommit(); |
| 600 } |
| 601 request->RequestComplete(); |
| 602 } |
| 603 |
| 580 //////////////////////////////////////////////////////////////////////////////// | 604 //////////////////////////////////////////////////////////////////////////////// |
| 581 // | 605 // |
| 582 // Web Apps implementation. | 606 // Web Apps implementation. |
| 583 // | 607 // |
| 584 //////////////////////////////////////////////////////////////////////////////// | 608 //////////////////////////////////////////////////////////////////////////////// |
| 585 | 609 |
| 586 void WebDataService::SetWebAppImageImpl( | 610 void WebDataService::SetWebAppImageImpl( |
| 587 GenericRequest2<GURL, SkBitmap>* request) { | 611 GenericRequest2<GURL, SkBitmap>* request) { |
| 588 if (db_ && !request->IsCancelled()) { | 612 if (db_ && !request->IsCancelled()) { |
| 589 db_->SetWebAppImage(request->GetArgument1(), request->GetArgument2()); | 613 db_->SetWebAppImage(request->GetArgument1(), request->GetArgument2()); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 Task* t = NewRunnableMethod(s, | 696 Task* t = NewRunnableMethod(s, |
| 673 &WebDataService::RequestCompleted, | 697 &WebDataService::RequestCompleted, |
| 674 handle_); | 698 handle_); |
| 675 message_loop_->PostTask(FROM_HERE, t); | 699 message_loop_->PostTask(FROM_HERE, t); |
| 676 } | 700 } |
| 677 | 701 |
| 678 int WebDataService::GetNextRequestHandle() { | 702 int WebDataService::GetNextRequestHandle() { |
| 679 AutoLock l(pending_lock_); | 703 AutoLock l(pending_lock_); |
| 680 return ++next_request_handle_; | 704 return ++next_request_handle_; |
| 681 } | 705 } |
| OLD | NEW |