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

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

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 | « chrome/browser/dom_ui/chrome_url_data_manager.h ('k') | no next file » | 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) 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 "chrome/browser/dom_ui/chrome_url_data_manager.h" 5 #include "chrome/browser/dom_ui/chrome_url_data_manager.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/ref_counted_memory.h" 11 #include "base/ref_counted_memory.h"
12 #include "base/singleton.h" 12 #include "base/singleton.h"
13 #include "base/stl_util-inl.h"
13 #include "base/string_util.h" 14 #include "base/string_util.h"
14 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
15 #include "base/values.h" 16 #include "base/values.h"
16 #if defined(OS_WIN) 17 #if defined(OS_WIN)
17 #include "base/win/windows_version.h" 18 #include "base/win/windows_version.h"
18 #endif 19 #endif
19 #include "chrome/browser/appcache/view_appcache_internals_job_factory.h" 20 #include "chrome/browser/appcache/view_appcache_internals_job_factory.h"
20 #include "chrome/browser/browser_thread.h" 21 #include "chrome/browser/browser_thread.h"
21 #include "chrome/browser/dom_ui/shared_resources_data_source.h" 22 #include "chrome/browser/dom_ui/shared_resources_data_source.h"
22 #include "chrome/browser/net/chrome_url_request_context.h" 23 #include "chrome/browser/net/chrome_url_request_context.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 if (p.IsAbsolute()) 170 if (p.IsAbsolute())
170 return false; 171 return false;
171 172
172 *file_path = i->second.AppendASCII(relative_path); 173 *file_path = i->second.AppendASCII(relative_path);
173 174
174 return true; 175 return true;
175 } 176 }
176 177
177 ChromeURLDataManager::ChromeURLDataManager() : next_request_id_(0) { } 178 ChromeURLDataManager::ChromeURLDataManager() : next_request_id_(0) { }
178 179
179 ChromeURLDataManager::~ChromeURLDataManager() { } 180 ChromeURLDataManager::~ChromeURLDataManager() {
181 // This is used as a Singleton, so it is only called at exit cleanup time.
182 // This means it is called on the main (UI) thread.
183 //
184 // It will break if it is called at shutdown time on a different thread, as
185 // it will attempt to call the destructors for its |data_source_|s on the
186 // UI thread, but the UI thread's message loop will be not be running
187 // -- so the destructor calls will be dropped and we will leak the objects.
188 }
180 189
181 // static 190 // static
182 ChromeURLDataManager* ChromeURLDataManager::GetInstance() { 191 ChromeURLDataManager* ChromeURLDataManager::GetInstance() {
183 return Singleton<ChromeURLDataManager>::get(); 192 return Singleton<ChromeURLDataManager>::get();
184 } 193 }
185 194
186 void ChromeURLDataManager::AddDataSource(scoped_refptr<DataSource> source) { 195 void ChromeURLDataManager::AddDataSource(scoped_refptr<DataSource> source) {
196 // Some |DataSource|-derived classes, notably |FileIconSource| and
197 // |DOMUIFavIconSource|, have members that will DCHECK if they are not
198 // destructed in the same thread as they are constructed (the UI thread).
199 //
200 // If |AddDataSource| is called more than once, it will destruct the object
201 // that it had before, as it is the only thing still holding a reference to
202 // that object. |DataSource| uses the |DeleteOnUIThread| trait to insure
203 // that the destructor is called on the UI thread.
204 //
187 // TODO(jackson): A new data source with same name should not clobber the 205 // TODO(jackson): A new data source with same name should not clobber the
188 // existing one. 206 // existing one.
189 data_sources_[source->source_name()] = source; 207 data_sources_[source->source_name()] = source;
190 } 208 }
191 209
192 void ChromeURLDataManager::AddFileSource(const std::string& source_name, 210 void ChromeURLDataManager::AddFileSource(const std::string& source_name,
193 const FilePath& file_path) { 211 const FilePath& file_path) {
194 DCHECK(file_sources_.count(source_name) == 0); 212 DCHECK(file_sources_.count(source_name) == 0);
195 file_sources_[source_name] = file_path; 213 file_sources_[source_name] = file_path;
196 } 214 }
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 net::ERR_INVALID_URL)); 450 net::ERR_INVALID_URL));
433 } 451 }
434 } 452 }
435 453
436 URLRequestChromeFileJob::URLRequestChromeFileJob(net::URLRequest* request, 454 URLRequestChromeFileJob::URLRequestChromeFileJob(net::URLRequest* request,
437 const FilePath& path) 455 const FilePath& path)
438 : net::URLRequestFileJob(request, path) { 456 : net::URLRequestFileJob(request, path) {
439 } 457 }
440 458
441 URLRequestChromeFileJob::~URLRequestChromeFileJob() { } 459 URLRequestChromeFileJob::~URLRequestChromeFileJob() { }
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/chrome_url_data_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698