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

Side by Side Diff: chrome/browser/webdata/web_data_request_manager.cc

Issue 11783091: Remove GenericRequest templates from WebDataService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Switch result_ to scopted_ptr Created 7 years, 11 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 | Annotate | Revision Log
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 "chrome/browser/webdata/web_data_request_manager.h" 5 #include "chrome/browser/webdata/web_data_request_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "chrome/browser/autofill/autofill_profile.h" 10 #include "chrome/browser/autofill/autofill_profile.h"
(...skipping 12 matching lines...) Expand all
23 : service_(service), 23 : service_(service),
24 cancelled_(false), 24 cancelled_(false),
25 consumer_(consumer), 25 consumer_(consumer),
26 result_(NULL) { 26 result_(NULL) {
27 handle_ = manager->GetNextRequestHandle(); 27 handle_ = manager->GetNextRequestHandle();
28 message_loop_ = MessageLoop::current(); 28 message_loop_ = MessageLoop::current();
29 manager->RegisterRequest(this); 29 manager->RegisterRequest(this);
30 } 30 }
31 31
32 WebDataRequest::~WebDataRequest() { 32 WebDataRequest::~WebDataRequest() {
33 delete result_;
34 } 33 }
35 34
36 WebDataService::Handle WebDataRequest::GetHandle() const { 35 WebDataService::Handle WebDataRequest::GetHandle() const {
37 return handle_; 36 return handle_;
38 } 37 }
39 38
40 WebDataServiceConsumer* WebDataRequest::GetConsumer() const { 39 WebDataServiceConsumer* WebDataRequest::GetConsumer() const {
41 return consumer_; 40 return consumer_;
42 } 41 }
43 42
44 bool WebDataRequest::IsCancelled() const { 43 bool WebDataRequest::IsCancelled() const {
45 base::AutoLock l(cancel_lock_); 44 base::AutoLock l(cancel_lock_);
46 return cancelled_; 45 return cancelled_;
47 } 46 }
48 47
49 void WebDataRequest::Cancel() { 48 void WebDataRequest::Cancel() {
50 base::AutoLock l(cancel_lock_); 49 base::AutoLock l(cancel_lock_);
51 cancelled_ = true; 50 cancelled_ = true;
52 consumer_ = NULL; 51 consumer_ = NULL;
53 } 52 }
54 53
55 void WebDataRequest::SetResult(WDTypedResult* r) { 54 void WebDataRequest::SetResult(scoped_ptr<WDTypedResult> r) {
56 result_ = r; 55 result_ = r.Pass();
57 } 56 }
58 57
59 const WDTypedResult* WebDataRequest::GetResult() const { 58 const WDTypedResult* WebDataRequest::GetResult() const {
60 return result_; 59 return result_.get();
61 } 60 }
62 61
63 void WebDataRequest::RequestComplete() { 62 void WebDataRequest::RequestComplete() {
64 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, 63 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted,
65 service_.get(), handle_)); 64 service_.get(), handle_));
66 } 65 }
67 66
68 //////////////////////////////////////////////////////////////////////////////// 67 ////////////////////////////////////////////////////////////////////////////////
69 // 68 //
70 // WebDataRequestManager implementation. 69 // WebDataRequestManager implementation.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 request->GetResult()); 118 request->GetResult());
120 } else { 119 } else {
121 // Nobody is taken ownership of the result, either because it is cancelled 120 // Nobody is taken ownership of the result, either because it is cancelled
122 // or there is no consumer. Destroy results that require special handling. 121 // or there is no consumer. Destroy results that require special handling.
123 WDTypedResult const *result = request->GetResult(); 122 WDTypedResult const *result = request->GetResult();
124 if (result) { 123 if (result) {
125 result->Destroy(); 124 result->Destroy();
126 } 125 }
127 } 126 }
128 } 127 }
OLDNEW
« no previous file with comments | « chrome/browser/webdata/web_data_request_manager.h ('k') | chrome/browser/webdata/web_data_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698