OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/webui/chrome_url_data_manager.h" | 5 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 ChromeURLDataManager::DataSource::DataSource(const std::string& source_name, | 123 ChromeURLDataManager::DataSource::DataSource(const std::string& source_name, |
124 MessageLoop* message_loop) | 124 MessageLoop* message_loop) |
125 : source_name_(source_name), | 125 : source_name_(source_name), |
126 message_loop_(message_loop), | 126 message_loop_(message_loop), |
127 backend_(NULL) { | 127 backend_(NULL) { |
128 } | 128 } |
129 | 129 |
130 ChromeURLDataManager::DataSource::~DataSource() { | 130 ChromeURLDataManager::DataSource::~DataSource() { |
131 } | 131 } |
132 | 132 |
133 void ChromeURLDataManager::DataSource::SendResponse(int request_id, | 133 void ChromeURLDataManager::DataSource::SendResponse( |
134 RefCountedMemory* bytes) { | 134 int request_id, |
| 135 base::RefCountedMemory* bytes) { |
135 // Take a ref-pointer on entry so byte->Release() will always get called. | 136 // Take a ref-pointer on entry so byte->Release() will always get called. |
136 scoped_refptr<RefCountedMemory> bytes_ptr(bytes); | 137 scoped_refptr<base::RefCountedMemory> bytes_ptr(bytes); |
137 if (IsScheduledForDeletion(this)) { | 138 if (IsScheduledForDeletion(this)) { |
138 // We're scheduled for deletion. Servicing the request would result in | 139 // We're scheduled for deletion. Servicing the request would result in |
139 // this->AddRef being invoked, even though the ref count is 0 and 'this' is | 140 // this->AddRef being invoked, even though the ref count is 0 and 'this' is |
140 // about to be deleted. If the AddRef were allowed through, when 'this' is | 141 // about to be deleted. If the AddRef were allowed through, when 'this' is |
141 // released it would be deleted again. | 142 // released it would be deleted again. |
142 // | 143 // |
143 // This scenario occurs with DataSources that make history requests. Such | 144 // This scenario occurs with DataSources that make history requests. Such |
144 // DataSources do a history query in |StartDataRequest| and the request is | 145 // DataSources do a history query in |StartDataRequest| and the request is |
145 // live until the object is deleted (history requests don't up the ref | 146 // live until the object is deleted (history requests don't up the ref |
146 // count). This means it's entirely possible for the DataSource to invoke | 147 // count). This means it's entirely possible for the DataSource to invoke |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 188 |
188 localized_strings->SetString("fontfamily", font_family); | 189 localized_strings->SetString("fontfamily", font_family); |
189 localized_strings->SetString("fontsize", | 190 localized_strings->SetString("fontsize", |
190 l10n_util::GetStringUTF8(web_font_size_id)); | 191 l10n_util::GetStringUTF8(web_font_size_id)); |
191 localized_strings->SetString("textdirection", | 192 localized_strings->SetString("textdirection", |
192 base::i18n::IsRTL() ? "rtl" : "ltr"); | 193 base::i18n::IsRTL() ? "rtl" : "ltr"); |
193 } | 194 } |
194 | 195 |
195 void ChromeURLDataManager::DataSource::SendResponseOnIOThread( | 196 void ChromeURLDataManager::DataSource::SendResponseOnIOThread( |
196 int request_id, | 197 int request_id, |
197 scoped_refptr<RefCountedMemory> bytes) { | 198 scoped_refptr<base::RefCountedMemory> bytes) { |
198 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 199 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
199 if (backend_) | 200 if (backend_) |
200 backend_->DataAvailable(request_id, bytes); | 201 backend_->DataAvailable(request_id, bytes); |
201 } | 202 } |
OLD | NEW |