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

Side by Side Diff: chrome/browser/dom_ui/chrome_url_data_manager.h

Issue 6285002: Fix for crash when deleting DataSource's in IO thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor cleanup. Created 9 years, 11 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 | « no previous file | chrome/browser/dom_ui/chrome_url_data_manager.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) 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_DOM_UI_CHROME_URL_DATA_MANAGER_H_ 5 #ifndef CHROME_BROWSER_DOM_UI_CHROME_URL_DATA_MANAGER_H_
6 #define CHROME_BROWSER_DOM_UI_CHROME_URL_DATA_MANAGER_H_ 6 #define CHROME_BROWSER_DOM_UI_CHROME_URL_DATA_MANAGER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 11
12 #include "base/singleton.h" 12 #include "base/singleton.h"
13 #include "base/task.h" 13 #include "base/task.h"
14 #include "base/ref_counted.h" 14 #include "base/ref_counted.h"
15 #include "chrome/browser/browser_thread.h"
15 16
16 class DictionaryValue; 17 class DictionaryValue;
17 class FilePath; 18 class FilePath;
18 class GURL; 19 class GURL;
19 class MessageLoop; 20 class MessageLoop;
20 class RefCountedMemory; 21 class RefCountedMemory;
21 class URLRequestChromeJob; 22 class URLRequestChromeJob;
22 23
23 namespace net { 24 namespace net {
24 class URLRequest; 25 class URLRequest;
(...skipping 10 matching lines...) Expand all
35 public: 36 public:
36 // Returns the singleton instance. 37 // Returns the singleton instance.
37 static ChromeURLDataManager* GetInstance(); 38 static ChromeURLDataManager* GetInstance();
38 39
39 typedef int RequestID; 40 typedef int RequestID;
40 41
41 // A DataSource is an object that can answer requests for data 42 // A DataSource is an object that can answer requests for data
42 // asynchronously. DataSources are collectively owned with refcounting smart 43 // asynchronously. DataSources are collectively owned with refcounting smart
43 // pointers and should never be deleted on the IO thread, since their calls 44 // pointers and should never be deleted on the IO thread, since their calls
44 // are handled almost always on the UI thread and there's a possibility of a 45 // are handled almost always on the UI thread and there's a possibility of a
45 // data race. 46 // data race. The |DeleteOnUIThread| trait is used to enforce this.
46 // 47 //
47 // An implementation of DataSource should handle calls to 48 // An implementation of DataSource should handle calls to
48 // StartDataRequest() by starting its (implementation-specific) asynchronous 49 // StartDataRequest() by starting its (implementation-specific) asynchronous
49 // request for the data, then call SendResponse() to notify 50 // request for the data, then call SendResponse() to notify.
50 class DataSource : public base::RefCountedThreadSafe<DataSource> { 51 class DataSource : public base::RefCountedThreadSafe<
52 DataSource, BrowserThread::DeleteOnUIThread> {
51 public: 53 public:
52 // See source_name_ and message_loop_ below for docs on these parameters. 54 // See source_name_ and message_loop_ below for docs on these parameters.
53 DataSource(const std::string& source_name, 55 DataSource(const std::string& source_name,
54 MessageLoop* message_loop); 56 MessageLoop* message_loop);
55 57
56 // Sent by the DataManager to request data at |path|. The source should 58 // Sent by the DataManager to request data at |path|. The source should
57 // call SendResponse() when the data is available or if the request could 59 // call SendResponse() when the data is available or if the request could
58 // not be satisfied. 60 // not be satisfied.
59 virtual void StartDataRequest(const std::string& path, 61 virtual void StartDataRequest(const std::string& path,
60 bool is_off_the_record, 62 bool is_off_the_record,
(...skipping 19 matching lines...) Expand all
80 // contention. 82 // contention.
81 virtual MessageLoop* MessageLoopForRequestPath(const std::string& path) 83 virtual MessageLoop* MessageLoopForRequestPath(const std::string& path)
82 const; 84 const;
83 85
84 const std::string& source_name() const { return source_name_; } 86 const std::string& source_name() const { return source_name_; }
85 87
86 static void SetFontAndTextDirection(DictionaryValue* localized_strings); 88 static void SetFontAndTextDirection(DictionaryValue* localized_strings);
87 89
88 protected: 90 protected:
89 friend class base::RefCountedThreadSafe<DataSource>; 91 friend class base::RefCountedThreadSafe<DataSource>;
92 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>;
93 friend class DeleteTask<DataSource>;
90 94
91 virtual ~DataSource(); 95 virtual ~DataSource();
92 96
93 private: 97 private:
94 // The name of this source. 98 // The name of this source.
95 // E.g., for favicons, this could be "favicon", which results in paths for 99 // E.g., for favicons, this could be "favicon", which results in paths for
96 // specific resources like "favicon/34" getting sent to this source. 100 // specific resources like "favicon/34" getting sent to this source.
97 const std::string source_name_; 101 const std::string source_name_;
98 102
99 // The MessageLoop for the thread where this DataSource lives. 103 // The MessageLoop for the thread where this DataSource lives.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 DISABLE_RUNNABLE_METHOD_REFCOUNT(ChromeURLDataManager); 179 DISABLE_RUNNABLE_METHOD_REFCOUNT(ChromeURLDataManager);
176 180
177 // Register our special URL handler under our special URL scheme. 181 // Register our special URL handler under our special URL scheme.
178 // Must be done once at startup. 182 // Must be done once at startup.
179 void RegisterURLRequestChromeJob(); 183 void RegisterURLRequestChromeJob();
180 184
181 // Undoes the registration done by RegisterURLRequestChromeJob. 185 // Undoes the registration done by RegisterURLRequestChromeJob.
182 void UnregisterURLRequestChromeJob(); 186 void UnregisterURLRequestChromeJob();
183 187
184 #endif // CHROME_BROWSER_DOM_UI_CHROME_URL_DATA_MANAGER_H_ 188 #endif // CHROME_BROWSER_DOM_UI_CHROME_URL_DATA_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/dom_ui/chrome_url_data_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698