OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/stl_util-inl.h" | 8 #include "base/stl_util-inl.h" |
9 #include "base/task.h" | 9 #include "base/task.h" |
10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 66 |
67 bool WebDataService::IsRunning() const { | 67 bool WebDataService::IsRunning() const { |
68 return is_running_; | 68 return is_running_; |
69 } | 69 } |
70 | 70 |
71 void WebDataService::UnloadDatabase() { | 71 void WebDataService::UnloadDatabase() { |
72 ScheduleTask(NewRunnableMethod(this, &WebDataService::ShutdownDatabase)); | 72 ScheduleTask(NewRunnableMethod(this, &WebDataService::ShutdownDatabase)); |
73 } | 73 } |
74 | 74 |
75 void WebDataService::CancelRequest(Handle h) { | 75 void WebDataService::CancelRequest(Handle h) { |
76 AutoLock l(pending_lock_); | 76 base::AutoLock l(pending_lock_); |
77 RequestMap::iterator i = pending_requests_.find(h); | 77 RequestMap::iterator i = pending_requests_.find(h); |
78 if (i == pending_requests_.end()) { | 78 if (i == pending_requests_.end()) { |
79 NOTREACHED() << "Canceling a nonexistent web data service request"; | 79 NOTREACHED() << "Canceling a nonexistent web data service request"; |
80 return; | 80 return; |
81 } | 81 } |
82 i->second->Cancel(); | 82 i->second->Cancel(); |
83 } | 83 } |
84 | 84 |
85 bool WebDataService::IsDatabaseLoaded() { | 85 bool WebDataService::IsDatabaseLoaded() { |
86 return db_ != NULL; | 86 return db_ != NULL; |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 static_cast<const WDResult<std::vector<CreditCard*> >*>(result); | 540 static_cast<const WDResult<std::vector<CreditCard*> >*>(result); |
541 | 541 |
542 std::vector<CreditCard*> credit_cards = r->GetValue(); | 542 std::vector<CreditCard*> credit_cards = r->GetValue(); |
543 STLDeleteElements(&credit_cards); | 543 STLDeleteElements(&credit_cards); |
544 } | 544 } |
545 } | 545 } |
546 } | 546 } |
547 } | 547 } |
548 | 548 |
549 void WebDataService::RegisterRequest(WebDataRequest* request) { | 549 void WebDataService::RegisterRequest(WebDataRequest* request) { |
550 AutoLock l(pending_lock_); | 550 base::AutoLock l(pending_lock_); |
551 pending_requests_[request->GetHandle()] = request; | 551 pending_requests_[request->GetHandle()] = request; |
552 } | 552 } |
553 | 553 |
554 //////////////////////////////////////////////////////////////////////////////// | 554 //////////////////////////////////////////////////////////////////////////////// |
555 // | 555 // |
556 // The following methods are executed in Chrome_WebDataThread. | 556 // The following methods are executed in Chrome_WebDataThread. |
557 // | 557 // |
558 //////////////////////////////////////////////////////////////////////////////// | 558 //////////////////////////////////////////////////////////////////////////////// |
559 | 559 |
560 void WebDataService::DBInitFailed(sql::InitStatus init_status) { | 560 void WebDataService::DBInitFailed(sql::InitStatus init_status) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 } | 630 } |
631 | 631 |
632 void WebDataService::ScheduleCommit() { | 632 void WebDataService::ScheduleCommit() { |
633 if (should_commit_ == false) { | 633 if (should_commit_ == false) { |
634 should_commit_ = true; | 634 should_commit_ = true; |
635 ScheduleTask(NewRunnableMethod(this, &WebDataService::Commit)); | 635 ScheduleTask(NewRunnableMethod(this, &WebDataService::Commit)); |
636 } | 636 } |
637 } | 637 } |
638 | 638 |
639 int WebDataService::GetNextRequestHandle() { | 639 int WebDataService::GetNextRequestHandle() { |
640 AutoLock l(pending_lock_); | 640 base::AutoLock l(pending_lock_); |
641 return ++next_request_handle_; | 641 return ++next_request_handle_; |
642 } | 642 } |
643 | 643 |
644 //////////////////////////////////////////////////////////////////////////////// | 644 //////////////////////////////////////////////////////////////////////////////// |
645 // | 645 // |
646 // Keywords implementation. | 646 // Keywords implementation. |
647 // | 647 // |
648 //////////////////////////////////////////////////////////////////////////////// | 648 //////////////////////////////////////////////////////////////////////////////// |
649 | 649 |
650 void WebDataService::AddKeywordImpl(GenericRequest<TemplateURL>* request) { | 650 void WebDataService::AddKeywordImpl(GenericRequest<TemplateURL>* request) { |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 return result_; | 1275 return result_; |
1276 } | 1276 } |
1277 | 1277 |
1278 void WebDataService::WebDataRequest::RequestComplete() { | 1278 void WebDataService::WebDataRequest::RequestComplete() { |
1279 WebDataService* s = service_; | 1279 WebDataService* s = service_; |
1280 Task* t = NewRunnableMethod(s, | 1280 Task* t = NewRunnableMethod(s, |
1281 &WebDataService::RequestCompleted, | 1281 &WebDataService::RequestCompleted, |
1282 handle_); | 1282 handle_); |
1283 message_loop_->PostTask(FROM_HERE, t); | 1283 message_loop_->PostTask(FROM_HERE, t); |
1284 } | 1284 } |
OLD | NEW |