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

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

Issue 3061009: Speculative fix for crash in DOMUIThumbnailSource. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: msvc++ caught this Created 10 years, 4 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
« no previous file with comments | « base/ref_counted_memory.cc ('k') | 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) 2006-2008 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/task.h" 12 #include "base/task.h"
13 #include "base/ref_counted_memory.h" 13 #include "base/ref_counted.h"
14 #include "chrome/browser/chrome_thread.h"
14 15
15 class DictionaryValue; 16 class DictionaryValue;
16 class FilePath; 17 class FilePath;
17 class GURL; 18 class GURL;
18 class MessageLoop; 19 class MessageLoop;
20 class RefCountedMemory;
19 class URLRequest; 21 class URLRequest;
20 class URLRequestChromeJob; 22 class URLRequestChromeJob;
21 class URLRequestJob; 23 class URLRequestJob;
22 24
23 // To serve dynamic data off of chrome: URLs, implement the 25 // To serve dynamic data off of chrome: URLs, implement the
24 // ChromeURLDataManager::DataSource interface and register your handler 26 // ChromeURLDataManager::DataSource interface and register your handler
25 // with AddDataSource. 27 // with AddDataSource.
26 28
27 // ChromeURLDataManager lives on the IO thread, so any interfacing with 29 // ChromeURLDataManager lives on the IO thread, so any interfacing with
28 // it from the UI thread needs to go through an InvokeLater. 30 // it from the UI thread needs to go through an InvokeLater.
29 class ChromeURLDataManager { 31 class ChromeURLDataManager {
30 public: 32 public:
31 ChromeURLDataManager(); 33 ChromeURLDataManager();
32 ~ChromeURLDataManager(); 34 ~ChromeURLDataManager();
33 35
34 typedef int RequestID; 36 typedef int RequestID;
35 37
36 // A DataSource is an object that can answer requests for data 38 // A DataSource is an object that can answer requests for data
37 // asynchronously. It should live on a thread that outlives the IO thread 39 // asynchronously. DataSources are collectively owned with refcounting smart
38 // (in particular, the UI thread). 40 // pointers and should never be deleted on the IO thread, since their calls
39 // An implementation of DataSource should handle calls to StartDataRequest() 41 // are handled almost always on the UI thread and there's a possibility of a
40 // by starting its (implementation-specific) asynchronous request for 42 // data race.
41 // the data, then call SendResponse() to notify 43 //
42 class DataSource : public base::RefCountedThreadSafe<DataSource> { 44 // An implementation of DataSource should handle calls to
45 // StartDataRequest() by starting its (implementation-specific) asynchronous
46 // request for the data, then call SendResponse() to notify
47 class DataSource
48 : public base::RefCountedThreadSafe<DataSource,
49 ChromeThread::DeleteOnUIThread> {
43 public: 50 public:
44 // See source_name_ and message_loop_ below for docs on these parameters. 51 // See source_name_ and message_loop_ below for docs on these parameters.
45 DataSource(const std::string& source_name, 52 DataSource(const std::string& source_name,
46 MessageLoop* message_loop) 53 MessageLoop* message_loop);
47 : source_name_(source_name), message_loop_(message_loop) {}
48 54
49 // Sent by the DataManager to request data at |path|. The source should 55 // Sent by the DataManager to request data at |path|. The source should
50 // call SendResponse() when the data is available or if the request could 56 // call SendResponse() when the data is available or if the request could
51 // not be satisfied. 57 // not be satisfied.
52 virtual void StartDataRequest(const std::string& path, 58 virtual void StartDataRequest(const std::string& path,
53 bool is_off_the_record, 59 bool is_off_the_record,
54 int request_id) = 0; 60 int request_id) = 0;
55 61
56 // Return the mimetype that should be sent with this response, or empty 62 // Return the mimetype that should be sent with this response, or empty
57 // string to specify no mime type. 63 // string to specify no mime type.
(...skipping 15 matching lines...) Expand all
73 // contention. 79 // contention.
74 virtual MessageLoop* MessageLoopForRequestPath(const std::string& path) 80 virtual MessageLoop* MessageLoopForRequestPath(const std::string& path)
75 const; 81 const;
76 82
77 const std::string& source_name() const { return source_name_; } 83 const std::string& source_name() const { return source_name_; }
78 84
79 static void SetFontAndTextDirection(DictionaryValue* localized_strings); 85 static void SetFontAndTextDirection(DictionaryValue* localized_strings);
80 86
81 protected: 87 protected:
82 friend class base::RefCountedThreadSafe<DataSource>; 88 friend class base::RefCountedThreadSafe<DataSource>;
89 friend struct ChromeThread::DeleteOnThread<ChromeThread::UI>;
90 friend class DeleteTask<DataSource>;
83 91
84 virtual ~DataSource() {} 92 virtual ~DataSource();
85 93
86 private: 94 private:
87 // The name of this source. 95 // The name of this source.
88 // E.g., for favicons, this could be "favicon", which results in paths for 96 // E.g., for favicons, this could be "favicon", which results in paths for
89 // specific resources like "favicon/34" getting sent to this source. 97 // specific resources like "favicon/34" getting sent to this source.
90 const std::string source_name_; 98 const std::string source_name_;
91 99
92 // The MessageLoop for the thread where this DataSource lives. 100 // The MessageLoop for the thread where this DataSource lives.
93 // Used to send messages to the DataSource. 101 // Used to send messages to the DataSource.
94 MessageLoop* message_loop_; 102 MessageLoop* message_loop_;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 DISABLE_RUNNABLE_METHOD_REFCOUNT(ChromeURLDataManager); 171 DISABLE_RUNNABLE_METHOD_REFCOUNT(ChromeURLDataManager);
164 172
165 // Register our special URL handler under our special URL scheme. 173 // Register our special URL handler under our special URL scheme.
166 // Must be done once at startup. 174 // Must be done once at startup.
167 void RegisterURLRequestChromeJob(); 175 void RegisterURLRequestChromeJob();
168 176
169 // Undoes the registration done by RegisterURLRequestChromeJob. 177 // Undoes the registration done by RegisterURLRequestChromeJob.
170 void UnregisterURLRequestChromeJob(); 178 void UnregisterURLRequestChromeJob();
171 179
172 #endif // CHROME_BROWSER_DOM_UI_CHROME_URL_DATA_MANAGER_H_ 180 #endif // CHROME_BROWSER_DOM_UI_CHROME_URL_DATA_MANAGER_H_
OLDNEW
« no previous file with comments | « base/ref_counted_memory.cc ('k') | chrome/browser/dom_ui/chrome_url_data_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698