| OLD | NEW |
| 1 // Copyright (c) 2011 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 "webkit/database/database_tracker.h" | 5 #include "webkit/database/database_tracker.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 DatabaseTracker::DatabaseTracker( | 93 DatabaseTracker::DatabaseTracker( |
| 94 const FilePath& profile_path, | 94 const FilePath& profile_path, |
| 95 bool is_incognito, | 95 bool is_incognito, |
| 96 bool clear_local_state_on_exit, | 96 bool clear_local_state_on_exit, |
| 97 quota::SpecialStoragePolicy* special_storage_policy, | 97 quota::SpecialStoragePolicy* special_storage_policy, |
| 98 quota::QuotaManagerProxy* quota_manager_proxy, | 98 quota::QuotaManagerProxy* quota_manager_proxy, |
| 99 base::MessageLoopProxy* db_tracker_thread) | 99 base::MessageLoopProxy* db_tracker_thread) |
| 100 : is_initialized_(false), | 100 : is_initialized_(false), |
| 101 is_incognito_(is_incognito), | 101 is_incognito_(is_incognito), |
| 102 clear_local_state_on_exit_(clear_local_state_on_exit), | 102 clear_local_state_on_exit_(clear_local_state_on_exit), |
| 103 save_session_state_(false), |
| 103 shutting_down_(false), | 104 shutting_down_(false), |
| 104 profile_path_(profile_path), | 105 profile_path_(profile_path), |
| 105 db_dir_(is_incognito_ ? | 106 db_dir_(is_incognito_ ? |
| 106 profile_path_.Append(kIncognitoDatabaseDirectoryName) : | 107 profile_path_.Append(kIncognitoDatabaseDirectoryName) : |
| 107 profile_path_.Append(kDatabaseDirectoryName)), | 108 profile_path_.Append(kDatabaseDirectoryName)), |
| 108 db_(new sql::Connection()), | 109 db_(new sql::Connection()), |
| 109 databases_table_(NULL), | 110 databases_table_(NULL), |
| 110 meta_table_(NULL), | 111 meta_table_(NULL), |
| 111 special_storage_policy_(special_storage_policy), | 112 special_storage_policy_(special_storage_policy), |
| 112 quota_manager_proxy_(quota_manager_proxy), | 113 quota_manager_proxy_(quota_manager_proxy), |
| (...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 | 851 |
| 851 void DatabaseTracker::Shutdown() { | 852 void DatabaseTracker::Shutdown() { |
| 852 DCHECK(db_tracker_thread_.get()); | 853 DCHECK(db_tracker_thread_.get()); |
| 853 DCHECK(db_tracker_thread_->BelongsToCurrentThread()); | 854 DCHECK(db_tracker_thread_->BelongsToCurrentThread()); |
| 854 if (shutting_down_) { | 855 if (shutting_down_) { |
| 855 NOTREACHED(); | 856 NOTREACHED(); |
| 856 return; | 857 return; |
| 857 } | 858 } |
| 858 if (is_incognito_) | 859 if (is_incognito_) |
| 859 DeleteIncognitoDBDirectory(); | 860 DeleteIncognitoDBDirectory(); |
| 860 else | 861 else if (!save_session_state_) |
| 861 ClearLocalState(clear_local_state_on_exit_); | 862 ClearLocalState(clear_local_state_on_exit_); |
| 862 } | 863 } |
| 863 | 864 |
| 864 void DatabaseTracker::SetClearLocalStateOnExit(bool clear_local_state_on_exit) { | 865 void DatabaseTracker::SetClearLocalStateOnExit(bool clear_local_state_on_exit) { |
| 865 DCHECK(db_tracker_thread_.get()); | 866 DCHECK(db_tracker_thread_.get()); |
| 866 if (!db_tracker_thread_->BelongsToCurrentThread()) { | 867 if (!db_tracker_thread_->BelongsToCurrentThread()) { |
| 867 db_tracker_thread_->PostTask( | 868 db_tracker_thread_->PostTask( |
| 868 FROM_HERE, | 869 FROM_HERE, |
| 869 base::Bind(&DatabaseTracker::SetClearLocalStateOnExit, this, | 870 base::Bind(&DatabaseTracker::SetClearLocalStateOnExit, this, |
| 870 clear_local_state_on_exit)); | 871 clear_local_state_on_exit)); |
| 871 return; | 872 return; |
| 872 } | 873 } |
| 873 if (shutting_down_) { | 874 if (shutting_down_) { |
| 874 NOTREACHED(); | 875 NOTREACHED(); |
| 875 return; | 876 return; |
| 876 } | 877 } |
| 877 clear_local_state_on_exit_ = clear_local_state_on_exit; | 878 clear_local_state_on_exit_ = clear_local_state_on_exit; |
| 878 } | 879 } |
| 879 | 880 |
| 881 void DatabaseTracker::SaveSessionState() { |
| 882 DCHECK(db_tracker_thread_.get()); |
| 883 if (!db_tracker_thread_->BelongsToCurrentThread()) { |
| 884 db_tracker_thread_->PostTask( |
| 885 FROM_HERE, |
| 886 base::Bind(&DatabaseTracker::SaveSessionState, this)); |
| 887 return; |
| 888 } |
| 889 save_session_state_ = true; |
| 890 } |
| 891 |
| 880 } // namespace webkit_database | 892 } // namespace webkit_database |
| OLD | NEW |