Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/debug/stack_trace.h" | |
|
eroman
2011/01/19 22:47:01
Is this intentional? Please remove.
ahendrickson
2011/01/21 16:04:31
Cleanup fail.
Removed.
| |
| 8 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 9 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| 10 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 11 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 12 #include "base/ref_counted_memory.h" | 13 #include "base/ref_counted_memory.h" |
| 13 #include "base/singleton.h" | 14 #include "base/singleton.h" |
| 15 #include "base/stl_util-inl.h" | |
| 14 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 15 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
| 16 #include "base/values.h" | 18 #include "base/values.h" |
| 17 #if defined(OS_WIN) | 19 #if defined(OS_WIN) |
| 18 #include "base/win/windows_version.h" | 20 #include "base/win/windows_version.h" |
| 19 #endif | 21 #endif |
| 20 #include "chrome/browser/appcache/view_appcache_internals_job_factory.h" | 22 #include "chrome/browser/appcache/view_appcache_internals_job_factory.h" |
| 21 #include "chrome/browser/browser_thread.h" | 23 #include "chrome/browser/browser_thread.h" |
| 22 #include "chrome/browser/dom_ui/shared_resources_data_source.h" | 24 #include "chrome/browser/dom_ui/shared_resources_data_source.h" |
| 23 #include "chrome/browser/net/chrome_url_request_context.h" | 25 #include "chrome/browser/net/chrome_url_request_context.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 ChromeURLDataManager::~ChromeURLDataManager() { } | 181 ChromeURLDataManager::~ChromeURLDataManager() { } |
| 180 | 182 |
| 181 // static | 183 // static |
| 182 ChromeURLDataManager* ChromeURLDataManager::GetInstance() { | 184 ChromeURLDataManager* ChromeURLDataManager::GetInstance() { |
| 183 return Singleton<ChromeURLDataManager>::get(); | 185 return Singleton<ChromeURLDataManager>::get(); |
| 184 } | 186 } |
| 185 | 187 |
| 186 void ChromeURLDataManager::AddDataSource(scoped_refptr<DataSource> source) { | 188 void ChromeURLDataManager::AddDataSource(scoped_refptr<DataSource> source) { |
| 187 // TODO(jackson): A new data source with same name should not clobber the | 189 // TODO(jackson): A new data source with same name should not clobber the |
| 188 // existing one. | 190 // existing one. |
| 191 if (ContainsKey(data_sources_, source->source_name())) { | |
| 192 // Some |DataSource| derived classes contain |CancellationFlag| members, | |
| 193 // which DCHECK if they are deleted in a different thread than they are | |
| 194 // created in. This is the IO thread, so we can't delete it here (for | |
| 195 // example, by reassigning a |data_sources_| entry). | |
| 196 // Create another reference and post a call to the UI thread to delete it. | |
| 197 // Any classes that weren't created on the UI thread are thread safe, | |
| 198 // and won't care if they're deleted on another thread. | |
| 199 BrowserThread::PostTask( | |
| 200 BrowserThread::UI, FROM_HERE, | |
| 201 NewRunnableMethod( | |
| 202 ChromeURLDataManager::GetInstance(), | |
| 203 &ChromeURLDataManager::ReleaseDataSource, | |
| 204 source)); | |
| 205 } | |
| 189 data_sources_[source->source_name()] = source; | 206 data_sources_[source->source_name()] = source; |
| 190 } | 207 } |
| 191 | 208 |
| 209 void ChromeURLDataManager::ReleaseDataSource(scoped_refptr<DataSource> source) { | |
| 210 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 211 source.release(); | |
| 212 } | |
| 213 | |
| 192 void ChromeURLDataManager::AddFileSource(const std::string& source_name, | 214 void ChromeURLDataManager::AddFileSource(const std::string& source_name, |
| 193 const FilePath& file_path) { | 215 const FilePath& file_path) { |
| 194 DCHECK(file_sources_.count(source_name) == 0); | 216 DCHECK(file_sources_.count(source_name) == 0); |
| 195 file_sources_[source_name] = file_path; | 217 file_sources_[source_name] = file_path; |
| 196 } | 218 } |
| 197 | 219 |
| 198 void ChromeURLDataManager::RemoveFileSource(const std::string& source_name) { | 220 void ChromeURLDataManager::RemoveFileSource(const std::string& source_name) { |
| 199 DCHECK(file_sources_.count(source_name) == 1); | 221 DCHECK(file_sources_.count(source_name) == 1); |
| 200 file_sources_.erase(source_name); | 222 file_sources_.erase(source_name); |
| 201 } | 223 } |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 431 net::ERR_INVALID_URL)); | 453 net::ERR_INVALID_URL)); |
| 432 } | 454 } |
| 433 } | 455 } |
| 434 | 456 |
| 435 URLRequestChromeFileJob::URLRequestChromeFileJob(net::URLRequest* request, | 457 URLRequestChromeFileJob::URLRequestChromeFileJob(net::URLRequest* request, |
| 436 const FilePath& path) | 458 const FilePath& path) |
| 437 : net::URLRequestFileJob(request, path) { | 459 : net::URLRequestFileJob(request, path) { |
| 438 } | 460 } |
| 439 | 461 |
| 440 URLRequestChromeFileJob::~URLRequestChromeFileJob() { } | 462 URLRequestChromeFileJob::~URLRequestChromeFileJob() { } |
| OLD | NEW |