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

Side by Side Diff: chrome/browser/in_process_webkit/webkit_context.h

Issue 5359005: Moved deleting the indexed db context to the WebKitContext destructor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Includes cleanup. Created 10 years 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_IN_PROCESS_WEBKIT_WEBKIT_CONTEXT_H_ 5 #ifndef CHROME_BROWSER_IN_PROCESS_WEBKIT_WEBKIT_CONTEXT_H_
6 #define CHROME_BROWSER_IN_PROCESS_WEBKIT_WEBKIT_CONTEXT_H_ 6 #define CHROME_BROWSER_IN_PROCESS_WEBKIT_WEBKIT_CONTEXT_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/lock.h"
12 #include "base/ref_counted.h" 13 #include "base/ref_counted.h"
13 #include "base/scoped_ptr.h" 14 #include "base/scoped_ptr.h"
14 #include "base/time.h" 15 #include "base/time.h"
15 #include "chrome/browser/in_process_webkit/dom_storage_context.h" 16 #include "chrome/browser/in_process_webkit/dom_storage_context.h"
16 #include "chrome/browser/in_process_webkit/indexed_db_context.h" 17 #include "chrome/browser/in_process_webkit/indexed_db_context.h"
18 #include "chrome/browser/prefs/pref_change_registrar.h"
19 #include "chrome/common/notification_observer.h"
17 20
18 class Profile; 21 class Profile;
19 22
20 // There's one WebKitContext per profile. Various DispatcherHost classes 23 // There's one WebKitContext per profile. Various DispatcherHost classes
21 // have a pointer to the Context to store shared state. Unfortunately, this 24 // have a pointer to the Context to store shared state. Unfortunately, this
22 // class has become a bit of a dumping ground for calls made on the UI thread 25 // class has become a bit of a dumping ground for calls made on the UI thread
23 // that need to be proxied over to the WebKit thread. 26 // that need to be proxied over to the WebKit thread.
24 // 27 //
25 // This class is created on the UI thread and accessed on the UI, IO, and WebKit 28 // This class is created on the UI thread and accessed on the UI, IO, and WebKit
26 // threads. 29 // threads.
27 class WebKitContext : public base::RefCountedThreadSafe<WebKitContext> { 30 class WebKitContext
31 : public NotificationObserver,
jochen (gone - plz use gerrit) 2010/11/27 19:02:27 notification observer is a pure virtual class, ref
pastarmovj 2010/11/27 20:45:15 Done.
32 public base::RefCountedThreadSafe<WebKitContext> {
28 public: 33 public:
29 explicit WebKitContext(Profile* profile); 34 explicit WebKitContext(Profile* profile);
30 35
31 const FilePath& data_path() const { return data_path_; } 36 const FilePath& data_path() const { return data_path_; }
32 bool is_incognito() const { return is_incognito_; } 37 bool is_incognito() const { return is_incognito_; }
38 bool clear_on_exit() const;
33 39
34 DOMStorageContext* dom_storage_context() { 40 DOMStorageContext* dom_storage_context() {
35 return dom_storage_context_.get(); 41 return dom_storage_context_.get();
36 } 42 }
37 43
38 IndexedDBContext* indexed_db_context() { 44 IndexedDBContext* indexed_db_context() {
39 return indexed_db_context_.get(); 45 return indexed_db_context_.get();
40 } 46 }
41 47
42 #ifdef UNIT_TEST 48 #ifdef UNIT_TEST
(...skipping 10 matching lines...) Expand all
53 // Tell all children (where applicable) to delete any objects that were 59 // Tell all children (where applicable) to delete any objects that were
54 // last modified on or after the following time. 60 // last modified on or after the following time.
55 void DeleteDataModifiedSince(const base::Time& cutoff, 61 void DeleteDataModifiedSince(const base::Time& cutoff,
56 const char* url_scheme_to_be_skipped, 62 const char* url_scheme_to_be_skipped,
57 const std::vector<string16>& protected_origins); 63 const std::vector<string16>& protected_origins);
58 64
59 // Delete the session storage namespace associated with this id. Can be 65 // Delete the session storage namespace associated with this id. Can be
60 // called from any thread. 66 // called from any thread.
61 void DeleteSessionStorageNamespace(int64 session_storage_namespace_id); 67 void DeleteSessionStorageNamespace(int64 session_storage_namespace_id);
62 68
69 // NotificationObserver implementation.
70 virtual void Observe(NotificationType type,
71 const NotificationSource& source,
72 const NotificationDetails& details);
73
63 private: 74 private:
64 friend class base::RefCountedThreadSafe<WebKitContext>; 75 friend class base::RefCountedThreadSafe<WebKitContext>;
65 ~WebKitContext(); 76 ~WebKitContext();
66 77
67 // Copies of profile data that can be accessed on any thread. 78 // Copies of profile data that can be accessed on any thread.
68 const FilePath data_path_; 79 const FilePath data_path_;
69 const bool is_incognito_; 80 const bool is_incognito_;
70 81
82 // Used around accesses to the clear_on_exit_ flag to guarantee thread safety.
83 mutable Lock lock_;
84 // When set the destructors of context objects will delete its files.
85 bool clear_on_exit_;
jochen (gone - plz use gerrit) 2010/11/27 19:02:27 I'd name this something like clear_local_state_on_
pastarmovj 2010/11/27 20:45:15 Done. I felt it would have been way too long and c
86
87 Profile* profile_;
jochen (gone - plz use gerrit) 2010/11/27 19:02:27 what do you need to profile for?
pastarmovj 2010/11/27 20:45:15 For the Observer to be able to extract the new pre
88 PrefChangeRegistrar pref_change_registrar_;
89
71 scoped_ptr<DOMStorageContext> dom_storage_context_; 90 scoped_ptr<DOMStorageContext> dom_storage_context_;
72 91
73 scoped_ptr<IndexedDBContext> indexed_db_context_; 92 scoped_ptr<IndexedDBContext> indexed_db_context_;
74 93
75 DISALLOW_IMPLICIT_CONSTRUCTORS(WebKitContext); 94 DISALLOW_IMPLICIT_CONSTRUCTORS(WebKitContext);
76 }; 95 };
77 96
78 #endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_WEBKIT_CONTEXT_H_ 97 #endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_WEBKIT_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698