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 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ |
6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 | 516 |
517 // Manages the non-thread safe (i.e. only to be accessed to the database's | 517 // Manages the non-thread safe (i.e. only to be accessed to the database's |
518 // main thread) state of this class. | 518 // main thread) state of this class. |
519 class DatabaseStateManager { | 519 class DatabaseStateManager { |
520 public: | 520 public: |
521 explicit DatabaseStateManager( | 521 explicit DatabaseStateManager( |
522 const scoped_refptr<const base::SequencedTaskRunner>& db_task_runner); | 522 const scoped_refptr<const base::SequencedTaskRunner>& db_task_runner); |
523 ~DatabaseStateManager(); | 523 ~DatabaseStateManager(); |
524 | 524 |
525 void init_filename_base(const base::FilePath& filename_base) { | 525 void init_filename_base(const base::FilePath& filename_base) { |
526 DCHECK(db_task_runner_->RunsTasksOnCurrentThread()); | 526 DCHECK(db_task_runner_->RunsTasksInCurrentSequence()); |
527 DCHECK(filename_base_.empty()) << "filename already initialized"; | 527 DCHECK(filename_base_.empty()) << "filename already initialized"; |
528 filename_base_ = filename_base; | 528 filename_base_ = filename_base; |
529 } | 529 } |
530 | 530 |
531 const base::FilePath& filename_base() { | 531 const base::FilePath& filename_base() { |
532 DCHECK(db_task_runner_->RunsTasksOnCurrentThread()); | 532 DCHECK(db_task_runner_->RunsTasksInCurrentSequence()); |
533 return filename_base_; | 533 return filename_base_; |
534 } | 534 } |
535 | 535 |
536 void set_corruption_detected() { | 536 void set_corruption_detected() { |
537 DCHECK(db_task_runner_->RunsTasksOnCurrentThread()); | 537 DCHECK(db_task_runner_->RunsTasksInCurrentSequence()); |
538 corruption_detected_ = true; | 538 corruption_detected_ = true; |
539 } | 539 } |
540 | 540 |
541 void reset_corruption_detected() { | 541 void reset_corruption_detected() { |
542 DCHECK(db_task_runner_->RunsTasksOnCurrentThread()); | 542 DCHECK(db_task_runner_->RunsTasksInCurrentSequence()); |
543 corruption_detected_ = false; | 543 corruption_detected_ = false; |
544 } | 544 } |
545 | 545 |
546 bool corruption_detected() { | 546 bool corruption_detected() { |
547 DCHECK(db_task_runner_->RunsTasksOnCurrentThread()); | 547 DCHECK(db_task_runner_->RunsTasksInCurrentSequence()); |
548 return corruption_detected_; | 548 return corruption_detected_; |
549 } | 549 } |
550 | 550 |
551 void set_change_detected() { | 551 void set_change_detected() { |
552 DCHECK(db_task_runner_->RunsTasksOnCurrentThread()); | 552 DCHECK(db_task_runner_->RunsTasksInCurrentSequence()); |
553 change_detected_ = true; | 553 change_detected_ = true; |
554 } | 554 } |
555 | 555 |
556 void reset_change_detected() { | 556 void reset_change_detected() { |
557 DCHECK(db_task_runner_->RunsTasksOnCurrentThread()); | 557 DCHECK(db_task_runner_->RunsTasksInCurrentSequence()); |
558 change_detected_ = false; | 558 change_detected_ = false; |
559 } | 559 } |
560 | 560 |
561 bool change_detected() { | 561 bool change_detected() { |
562 DCHECK(db_task_runner_->RunsTasksOnCurrentThread()); | 562 DCHECK(db_task_runner_->RunsTasksInCurrentSequence()); |
563 return change_detected_; | 563 return change_detected_; |
564 } | 564 } |
565 | 565 |
566 private: | 566 private: |
567 // The sequenced task runner for this object, used to verify that its state | 567 // The sequenced task runner for this object, used to verify that its state |
568 // is only ever accessed from the runner. | 568 // is only ever accessed from the runner. |
569 scoped_refptr<const base::SequencedTaskRunner> db_task_runner_; | 569 scoped_refptr<const base::SequencedTaskRunner> db_task_runner_; |
570 | 570 |
571 // The base filename passed to Init(), used to generate the store and prefix | 571 // The base filename passed to Init(), used to generate the store and prefix |
572 // set filenames used to store data on disk. | 572 // set filenames used to store data on disk. |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 | 731 |
732 // Used to schedule resetting the database because of corruption. This factory | 732 // Used to schedule resetting the database because of corruption. This factory |
733 // and the WeakPtrs it issues should only be used on the database's main | 733 // and the WeakPtrs it issues should only be used on the database's main |
734 // thread. | 734 // thread. |
735 base::WeakPtrFactory<SafeBrowsingDatabaseNew> reset_factory_; | 735 base::WeakPtrFactory<SafeBrowsingDatabaseNew> reset_factory_; |
736 }; | 736 }; |
737 | 737 |
738 } // namespace safe_browsing | 738 } // namespace safe_browsing |
739 | 739 |
740 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ | 740 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ |
OLD | NEW |