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

Side by Side Diff: content/child/web_database_observer_impl.cc

Issue 1832473002: WebSQL: Use url::Origin rather than database identifiers for IPC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 6 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 | « content/child/db_message_filter.cc ('k') | content/common/database_messages.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "content/child/web_database_observer_impl.h" 5 #include "content/child/web_database_observer_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 74 }
75 75
76 WebDatabaseObserverImpl::~WebDatabaseObserverImpl() { 76 WebDatabaseObserverImpl::~WebDatabaseObserverImpl() {
77 } 77 }
78 78
79 void WebDatabaseObserverImpl::databaseOpened( 79 void WebDatabaseObserverImpl::databaseOpened(
80 const WebSecurityOrigin& origin, 80 const WebSecurityOrigin& origin,
81 const WebString& database_name, 81 const WebString& database_name,
82 const WebString& database_display_name, 82 const WebString& database_display_name,
83 unsigned long estimated_size) { 83 unsigned long estimated_size) {
84 const std::string origin_identifier = GetIdentifierFromOrigin(origin); 84 open_connections_->AddOpenConnection(GetIdentifierFromOrigin(origin),
85 open_connections_->AddOpenConnection(origin_identifier, database_name); 85 database_name);
86 sender_->Send(new DatabaseHostMsg_Opened( 86 sender_->Send(new DatabaseHostMsg_Opened(
87 origin_identifier, database_name, database_display_name, estimated_size)); 87 origin, database_name, database_display_name, estimated_size));
88 } 88 }
89 89
90 void WebDatabaseObserverImpl::databaseModified(const WebSecurityOrigin& origin, 90 void WebDatabaseObserverImpl::databaseModified(const WebSecurityOrigin& origin,
91 const WebString& database_name) { 91 const WebString& database_name) {
92 sender_->Send(new DatabaseHostMsg_Modified(GetIdentifierFromOrigin(origin), 92 sender_->Send(new DatabaseHostMsg_Modified(origin, database_name));
93 database_name));
94 } 93 }
95 94
96 void WebDatabaseObserverImpl::databaseClosed(const WebSecurityOrigin& origin, 95 void WebDatabaseObserverImpl::databaseClosed(const WebSecurityOrigin& origin,
97 const WebString& database_name) { 96 const WebString& database_name) {
98 DCHECK(!main_thread_task_runner_->RunsTasksOnCurrentThread()); 97 DCHECK(!main_thread_task_runner_->RunsTasksOnCurrentThread());
99 const std::string origin_identifier = GetIdentifierFromOrigin(origin);
100 main_thread_task_runner_->PostTask( 98 main_thread_task_runner_->PostTask(
101 FROM_HERE, 99 FROM_HERE,
102 base::Bind(base::IgnoreResult(&IPC::SyncMessageFilter::Send), sender_, 100 base::Bind(base::IgnoreResult(&IPC::SyncMessageFilter::Send), sender_,
103 new DatabaseHostMsg_Closed(origin_identifier, database_name))); 101 new DatabaseHostMsg_Closed(origin, database_name)));
104 open_connections_->RemoveOpenConnection(origin_identifier, database_name); 102 open_connections_->RemoveOpenConnection(GetIdentifierFromOrigin(origin),
103 database_name);
105 } 104 }
106 105
107 void WebDatabaseObserverImpl::reportOpenDatabaseResult( 106 void WebDatabaseObserverImpl::reportOpenDatabaseResult(
108 const WebSecurityOrigin& origin, 107 const WebSecurityOrigin& origin,
109 const WebString& database_name, 108 const WebString& database_name,
110 int callsite, 109 int callsite,
111 int websql_error, 110 int websql_error,
112 int sqlite_error, 111 int sqlite_error,
113 double call_time) { 112 double call_time) {
114 UMA_HISTOGRAM_WEBSQL_RESULT("OpenResult", callsite, 113 UMA_HISTOGRAM_WEBSQL_RESULT("OpenResult", callsite,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 return open_connections_->WaitForAllDatabasesToClose(timeout); 183 return open_connections_->WaitForAllDatabasesToClose(timeout);
185 } 184 }
186 185
187 void WebDatabaseObserverImpl::HandleSqliteError(const WebSecurityOrigin& origin, 186 void WebDatabaseObserverImpl::HandleSqliteError(const WebSecurityOrigin& origin,
188 const WebString& database_name, 187 const WebString& database_name,
189 int error) { 188 int error) {
190 // We filter out errors which the backend doesn't act on to avoid 189 // We filter out errors which the backend doesn't act on to avoid
191 // a unnecessary ipc traffic, this method can get called at a fairly 190 // a unnecessary ipc traffic, this method can get called at a fairly
192 // high frequency (per-sqlstatement). 191 // high frequency (per-sqlstatement).
193 if (error == SQLITE_CORRUPT || error == SQLITE_NOTADB) { 192 if (error == SQLITE_CORRUPT || error == SQLITE_NOTADB) {
194 sender_->Send(new DatabaseHostMsg_HandleSqliteError( 193 sender_->Send(
195 GetIdentifierFromOrigin(origin), database_name, error)); 194 new DatabaseHostMsg_HandleSqliteError(origin, database_name, error));
196 } 195 }
197 } 196 }
198 197
199 } // namespace content 198 } // namespace content
OLDNEW
« no previous file with comments | « content/child/db_message_filter.cc ('k') | content/common/database_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698