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

Side by Side Diff: android_webview/browser/aw_form_database_service.cc

Issue 2817923003: aw: Add allow wait for form database (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | android_webview/javatests/src/org/chromium/android_webview/test/AwFormDatabaseTest.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "android_webview/browser/aw_form_database_service.h" 5 #include "android_webview/browser/aw_form_database_service.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "base/threading/thread_restrictions.h"
10 #include "components/autofill/core/browser/webdata/autofill_table.h" 11 #include "components/autofill/core/browser/webdata/autofill_table.h"
11 #include "components/webdata/common/webdata_constants.h" 12 #include "components/webdata/common/webdata_constants.h"
12 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
13 14
14 using base::WaitableEvent; 15 using base::WaitableEvent;
15 using content::BrowserThread; 16 using content::BrowserThread;
16 17
17 namespace { 18 namespace {
18 19
19 // Callback to handle database error. It seems chrome uses this to 20 // Callback to handle database error. It seems chrome uses this to
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 WaitableEvent completion(base::WaitableEvent::ResetPolicy::AUTOMATIC, 82 WaitableEvent completion(base::WaitableEvent::ResetPolicy::AUTOMATIC,
82 base::WaitableEvent::InitialState::NOT_SIGNALED); 83 base::WaitableEvent::InitialState::NOT_SIGNALED);
83 bool result = false; 84 bool result = false;
84 BrowserThread::PostTask( 85 BrowserThread::PostTask(
85 BrowserThread::DB, 86 BrowserThread::DB,
86 FROM_HERE, 87 FROM_HERE,
87 base::Bind(&AwFormDatabaseService::HasFormDataImpl, 88 base::Bind(&AwFormDatabaseService::HasFormDataImpl,
88 base::Unretained(this), 89 base::Unretained(this),
89 &completion, 90 &completion,
90 &result)); 91 &result));
91 completion.Wait(); 92 {
93 base::ThreadRestrictions::ScopedAllowWait wait;
94 completion.Wait();
95 }
92 return result; 96 return result;
93 } 97 }
94 98
95 void AwFormDatabaseService::HasFormDataImpl( 99 void AwFormDatabaseService::HasFormDataImpl(
96 WaitableEvent* completion, 100 WaitableEvent* completion,
97 bool* result) { 101 bool* result) {
98 WebDataServiceBase::Handle pending_query_handle = 102 WebDataServiceBase::Handle pending_query_handle =
99 autofill_data_->GetCountOfValuesContainedBetween( 103 autofill_data_->GetCountOfValuesContainedBetween(
100 base::Time(), base::Time::Max(), this); 104 base::Time(), base::Time::Max(), this);
101 PendingQuery query; 105 PendingQuery query;
(...skipping 17 matching lines...) Expand all
119 if (it == result_map_.end()) { 123 if (it == result_map_.end()) {
120 LOG(WARNING) << "Received unexpected callback from web data service"; 124 LOG(WARNING) << "Received unexpected callback from web data service";
121 return; 125 return;
122 } 126 }
123 *(it->second.result) = has_form_data; 127 *(it->second.result) = has_form_data;
124 it->second.completion->Signal(); 128 it->second.completion->Signal();
125 result_map_.erase(h); 129 result_map_.erase(h);
126 } 130 }
127 131
128 } // namespace android_webview 132 } // namespace android_webview
OLDNEW
« no previous file with comments | « no previous file | android_webview/javatests/src/org/chromium/android_webview/test/AwFormDatabaseTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698