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

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

Issue 9614002: Use SyncMessageFilter to Send() ipc messages from background threads. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "content/common/web_database_observer_impl.h" 5 #include "content/common/web_database_observer_impl.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/string16.h" 8 #include "base/string16.h"
9 #include "content/common/database_messages.h" 9 #include "content/common/database_messages.h"
10 #include "third_party/sqlite/sqlite3.h" 10 #include "third_party/sqlite/sqlite3.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDatabase.h" 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDatabase.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" 12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
13 13
14 #include "base/rand_util.h"
15
14 using WebKit::WebDatabase; 16 using WebKit::WebDatabase;
15 17
16 namespace { 18 namespace {
17 19
18 const int kResultHistogramSize = 50; 20 const int kResultHistogramSize = 50;
19 const int kCallsiteHistogramSize = 10; 21 const int kCallsiteHistogramSize = 10;
20 22
21 int DetermineHistogramResult(int websql_error, int sqlite_error) { 23 int DetermineHistogramResult(int websql_error, int sqlite_error) {
22 // If we have a sqlite error, log it after trimming the extended bits. 24 // If we have a sqlite error, log it after trimming the extended bits.
23 // There are 26 possible values, but we leave room for some new ones. 25 // There are 26 possible values, but we leave room for some new ones.
(...skipping 30 matching lines...) Expand all
54 if (result) { \ 56 if (result) { \
55 UMA_HISTOGRAM_ENUMERATION("websql.Async." name ".ErrorSite", \ 57 UMA_HISTOGRAM_ENUMERATION("websql.Async." name ".ErrorSite", \
56 callsite, kCallsiteHistogramSize); \ 58 callsite, kCallsiteHistogramSize); \
57 } \ 59 } \
58 } \ 60 } \
59 } while (0) 61 } while (0)
60 62
61 } // namespace 63 } // namespace
62 64
63 WebDatabaseObserverImpl::WebDatabaseObserverImpl( 65 WebDatabaseObserverImpl::WebDatabaseObserverImpl(
64 IPC::Message::Sender* sender) 66 IPC::SyncMessageFilter* sender)
65 : sender_(sender), 67 : sender_(sender),
66 open_connections_(new webkit_database::DatabaseConnectionsWrapper) { 68 open_connections_(new webkit_database::DatabaseConnectionsWrapper) {
67 } 69 }
68 70
69 WebDatabaseObserverImpl::~WebDatabaseObserverImpl() { 71 WebDatabaseObserverImpl::~WebDatabaseObserverImpl() {
70 } 72 }
71 73
72 void WebDatabaseObserverImpl::databaseOpened( 74 void WebDatabaseObserverImpl::databaseOpened(
73 const WebDatabase& database) { 75 const WebDatabase& database) {
74 string16 origin_identifier = database.securityOrigin().databaseIdentifier(); 76 string16 origin_identifier = database.securityOrigin().databaseIdentifier();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 } 148 }
147 HandleSqliteError(database, sqlite_error); 149 HandleSqliteError(database, sqlite_error);
148 } 150 }
149 151
150 void WebDatabaseObserverImpl::WaitForAllDatabasesToClose() { 152 void WebDatabaseObserverImpl::WaitForAllDatabasesToClose() {
151 open_connections_->WaitForAllDatabasesToClose(); 153 open_connections_->WaitForAllDatabasesToClose();
152 } 154 }
153 155
154 void WebDatabaseObserverImpl::HandleSqliteError( 156 void WebDatabaseObserverImpl::HandleSqliteError(
155 const WebDatabase& database, int error) { 157 const WebDatabase& database, int error) {
158 // JUNK TO INDUCE ERRORS
159 int rand = base::RandInt(0, 10000);
160 if (rand < 5)
161 error = SQLITE_CORRUPT;
162 // JUNK TO INDUCE ERRORS
michaeln 2012/03/06 00:39:18 oh... nevermind this JUNK and the base/rand_util i
163
156 // We filter out errors which the backend doesn't act on to avoid 164 // We filter out errors which the backend doesn't act on to avoid
157 // a unnecessary ipc traffic, this method can get called at a fairly 165 // a unnecessary ipc traffic, this method can get called at a fairly
158 // high frequency (per-sqlstatement). 166 // high frequency (per-sqlstatement).
159 if (error == SQLITE_CORRUPT || error == SQLITE_NOTADB) { 167 if (error == SQLITE_CORRUPT || error == SQLITE_NOTADB) {
160 sender_->Send(new DatabaseHostMsg_HandleSqliteError( 168 sender_->Send(new DatabaseHostMsg_HandleSqliteError(
161 database.securityOrigin().databaseIdentifier(), 169 database.securityOrigin().databaseIdentifier(),
162 database.name(), 170 database.name(),
163 error)); 171 error));
164 } 172 }
165 } 173 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698