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

Side by Side Diff: chrome/browser/password_manager/password_store_win.cc

Issue 6646051: Fix DCHECK, memory leak, and refactor PasswordStore to use CancelableRequest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use non-zero tests until http://crbug.com/77650 is addressed. Created 9 years, 9 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 (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/password_manager/password_store_win.h" 5 #include "chrome/browser/password_manager/password_store_win.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/password_manager/ie7_password.h" 10 #include "chrome/browser/password_manager/ie7_password.h"
11 #include "chrome/browser/password_manager/password_manager.h" 11 #include "chrome/browser/password_manager/password_manager.h"
(...skipping 17 matching lines...) Expand all
29 } 29 }
30 30
31 int PasswordStoreWin::GetLogins(const webkit_glue::PasswordForm& form, 31 int PasswordStoreWin::GetLogins(const webkit_glue::PasswordForm& form,
32 PasswordStoreConsumer* consumer) { 32 PasswordStoreConsumer* consumer) {
33 int request_handle = PasswordStoreDefault::GetLogins(form, consumer); 33 int request_handle = PasswordStoreDefault::GetLogins(form, consumer);
34 pending_request_forms_.insert(PendingRequestFormMap::value_type( 34 pending_request_forms_.insert(PendingRequestFormMap::value_type(
35 request_handle, form)); 35 request_handle, form));
36 return request_handle; 36 return request_handle;
37 } 37 }
38 38
39 void PasswordStoreWin::NotifyConsumer(GetLoginsRequest* request, 39 void PasswordStoreWin::ForwardLoginsResult(GetLoginsRequest* request) {
40 const std::vector<PasswordForm*> forms) { 40 if (!request->value.empty()) {
41 if (!forms.empty()) { 41 pending_request_forms_.erase(request->handle());
42 pending_request_forms_.erase(request->handle); 42 PasswordStore::ForwardLoginsResult(request);
43 PasswordStore::NotifyConsumer(request, forms);
44 } else { 43 } else {
45 PendingRequestFormMap::iterator it(pending_request_forms_.find( 44 PendingRequestFormMap::iterator it(pending_request_forms_.find(
46 request->handle)); 45 request->handle()));
47 if (it != pending_request_forms_.end()) { 46 if (it != pending_request_forms_.end()) {
48 IE7PasswordInfo info; 47 IE7PasswordInfo info;
49 std::wstring url = ASCIIToWide(it->second.origin.spec()); 48 std::wstring url = ASCIIToWide(it->second.origin.spec());
50 info.url_hash = ie7_password::GetUrlHash(url); 49 info.url_hash = ie7_password::GetUrlHash(url);
51 WebDataService::Handle handle = web_data_service_->GetIE7Login(info, 50 WebDataService::Handle handle = web_data_service_->GetIE7Login(info,
52 this); 51 this);
53 TrackRequest(handle, request); 52 TrackRequest(handle, request);
54 } 53 }
55 } 54 }
56 } 55 }
57 56
58 void PasswordStoreWin::OnWebDataServiceRequestDone( 57 void PasswordStoreWin::OnWebDataServiceRequestDone(
59 WebDataService::Handle handle, const WDTypedResult* result) { 58 WebDataService::Handle handle, const WDTypedResult* result) {
60 if (!result) 59 if (!result)
61 return; // The WDS returns NULL if it is shutting down. 60 return; // The WDS returns NULL if it is shutting down.
62 61
63 if (PASSWORD_IE7_RESULT == result->GetType()) { 62 if (PASSWORD_IE7_RESULT == result->GetType()) {
64 scoped_ptr<GetLoginsRequest> request(TakeRequestWithHandle(handle)); 63 scoped_ptr<GetLoginsRequest> request(TakeRequestWithHandle(handle));
65 64
66 // If the request was cancelled, we are done. 65 // If the request was cancelled, we are done.
67 if (!request.get()) 66 if (!request.get())
68 return; 67 return;
69 68
70 // This is a response from WebDataService::GetIE7Login. 69 // This is a response from WebDataService::GetIE7Login.
71 PendingRequestFormMap::iterator it(pending_request_forms_.find( 70 PendingRequestFormMap::iterator it(pending_request_forms_.find(
72 request->handle)); 71 request->handle()));
73 DCHECK(pending_request_forms_.end() != it); 72 DCHECK(pending_request_forms_.end() != it);
74 PasswordForm* ie7_form = GetIE7Result(result, it->second); 73 PasswordForm* ie7_form = GetIE7Result(result, it->second);
75 74
76 std::vector<PasswordForm*> forms;
77 if (ie7_form) 75 if (ie7_form)
78 forms.push_back(ie7_form); 76 request->value.push_back(ie7_form);
79 77
80 pending_request_forms_.erase(it); 78 pending_request_forms_.erase(it);
81 PasswordStore::NotifyConsumer(request.release(), forms); 79 PasswordStore::ForwardLoginsResult(request.release());
82 } else { 80 } else {
83 PasswordStoreDefault::OnWebDataServiceRequestDone(handle, result); 81 PasswordStoreDefault::OnWebDataServiceRequestDone(handle, result);
84 } 82 }
85 } 83 }
86 84
87 void PasswordStoreWin::TrackRequest(WebDataService::Handle handle, 85 void PasswordStoreWin::TrackRequest(WebDataService::Handle handle,
88 GetLoginsRequest* request) { 86 GetLoginsRequest* request) {
89 pending_requests_.insert(PendingRequestMap::value_type(handle, request)); 87 pending_requests_.insert(PendingRequestMap::value_type(handle, request));
90 } 88 }
91 89
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 auto_fill->password_value = password; 122 auto_fill->password_value = password;
125 auto_fill->preferred = true; 123 auto_fill->preferred = true;
126 auto_fill->ssl_valid = form.origin.SchemeIsSecure(); 124 auto_fill->ssl_valid = form.origin.SchemeIsSecure();
127 auto_fill->date_created = info.date_created; 125 auto_fill->date_created = info.date_created;
128 // Add this PasswordForm to the saved password table. 126 // Add this PasswordForm to the saved password table.
129 AddLogin(*auto_fill); 127 AddLogin(*auto_fill);
130 return auto_fill; 128 return auto_fill;
131 } 129 }
132 return NULL; 130 return NULL;
133 } 131 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_store_win.h ('k') | chrome/browser/password_manager/password_store_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698