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

Side by Side Diff: sql/connection.h

Issue 5125579611308032: [sql] Allow restricting database to user read access. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments about posix-specificness. Created 7 years, 5 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
« no previous file with comments | « chrome/browser/password_manager/login_database_unittest.cc ('k') | sql/connection.cc » ('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) 2012 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 #ifndef SQL_CONNECTION_H_ 5 #ifndef SQL_CONNECTION_H_
6 #define SQL_CONNECTION_H_ 6 #define SQL_CONNECTION_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // transaition (requires another access to the DB) and because we don't 109 // transaition (requires another access to the DB) and because we don't
110 // actually need it. 110 // actually need it.
111 // 111 //
112 // Exclusive mode means that the database is not unlocked at the end of each 112 // Exclusive mode means that the database is not unlocked at the end of each
113 // transaction, which means there may be less time spent initializing the 113 // transaction, which means there may be less time spent initializing the
114 // next transaction because it doesn't have to re-aquire locks. 114 // next transaction because it doesn't have to re-aquire locks.
115 // 115 //
116 // This must be called before Open() to have an effect. 116 // This must be called before Open() to have an effect.
117 void set_exclusive_locking() { exclusive_locking_ = true; } 117 void set_exclusive_locking() { exclusive_locking_ = true; }
118 118
119 // Call to cause Open() to restrict access permissions of the
120 // database file to only the owner.
121 // TODO(shess): Currently only supported on OS_POSIX, is a noop on
122 // other platforms.
123 void set_restrict_to_user() { restrict_to_user_ = true; }
124
119 // Set an error-handling callback. On errors, the error number (and 125 // Set an error-handling callback. On errors, the error number (and
120 // statement, if available) will be passed to the callback. 126 // statement, if available) will be passed to the callback.
121 // 127 //
122 // If no callback is set, the default action is to crash in debug 128 // If no callback is set, the default action is to crash in debug
123 // mode or return failure in release mode. 129 // mode or return failure in release mode.
124 typedef base::Callback<void(int, Statement*)> ErrorCallback; 130 typedef base::Callback<void(int, Statement*)> ErrorCallback;
125 void set_error_callback(const ErrorCallback& callback) { 131 void set_error_callback(const ErrorCallback& callback) {
126 error_callback_ = callback; 132 error_callback_ = callback;
127 } 133 }
128 bool has_error_callback() const { 134 bool has_error_callback() const {
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 480
475 // The actual sqlite database. Will be NULL before Init has been called or if 481 // The actual sqlite database. Will be NULL before Init has been called or if
476 // Init resulted in an error. 482 // Init resulted in an error.
477 sqlite3* db_; 483 sqlite3* db_;
478 484
479 // Parameters we'll configure in sqlite before doing anything else. Zero means 485 // Parameters we'll configure in sqlite before doing anything else. Zero means
480 // use the default value. 486 // use the default value.
481 int page_size_; 487 int page_size_;
482 int cache_size_; 488 int cache_size_;
483 bool exclusive_locking_; 489 bool exclusive_locking_;
490 bool restrict_to_user_;
484 491
485 // All cached statements. Keeping a reference to these statements means that 492 // All cached statements. Keeping a reference to these statements means that
486 // they'll remain active. 493 // they'll remain active.
487 typedef std::map<StatementID, scoped_refptr<StatementRef> > 494 typedef std::map<StatementID, scoped_refptr<StatementRef> >
488 CachedStatementMap; 495 CachedStatementMap;
489 CachedStatementMap statement_cache_; 496 CachedStatementMap statement_cache_;
490 497
491 // A list of all StatementRefs we've given out. Each ref must register with 498 // A list of all StatementRefs we've given out. Each ref must register with
492 // us when it's created or destroyed. This allows us to potentially close 499 // us when it's created or destroyed. This allows us to potentially close
493 // any open statements when we encounter an error. 500 // any open statements when we encounter an error.
(...skipping 22 matching lines...) Expand all
516 523
517 // Tag for auxiliary histograms. 524 // Tag for auxiliary histograms.
518 std::string histogram_tag_; 525 std::string histogram_tag_;
519 526
520 DISALLOW_COPY_AND_ASSIGN(Connection); 527 DISALLOW_COPY_AND_ASSIGN(Connection);
521 }; 528 };
522 529
523 } // namespace sql 530 } // namespace sql
524 531
525 #endif // SQL_CONNECTION_H_ 532 #endif // SQL_CONNECTION_H_
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/login_database_unittest.cc ('k') | sql/connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698