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

Side by Side Diff: content/browser/webui/url_data_source_impl.cc

Issue 12093012: Clean up of url data manager classes in content: move URLDataSourceImpl to its own file, move all t… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 10 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/webui/url_data_source_impl.h"
6
7 #include "base/bind.h"
8 #include "base/memory/ref_counted_memory.h"
9 #include "base/string_util.h"
10 #include "content/browser/webui/url_data_manager_backend.h"
11 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/url_data_source.h"
13
14 namespace content {
15
16 URLDataSourceImpl::URLDataSourceImpl(const std::string& source_name,
17 URLDataSource* source)
18 : source_name_(source_name),
19 backend_(NULL),
20 source_(source) {
21 }
22
23 URLDataSourceImpl::~URLDataSourceImpl() {
24 }
25
26 void URLDataSourceImpl::SendResponse(
27 int request_id,
28 base::RefCountedMemory* bytes) {
29 // Take a ref-pointer on entry so byte->Release() will always get called.
30 scoped_refptr<base::RefCountedMemory> bytes_ptr(bytes);
31 if (URLDataManager::IsScheduledForDeletion(this)) {
32 // We're scheduled for deletion. Servicing the request would result in
33 // this->AddRef being invoked, even though the ref count is 0 and 'this' is
34 // about to be deleted. If the AddRef were allowed through, when 'this' is
35 // released it would be deleted again.
36 //
37 // This scenario occurs with DataSources that make history requests. Such
38 // DataSources do a history query in |StartDataRequest| and the request is
39 // live until the object is deleted (history requests don't up the ref
40 // count). This means it's entirely possible for the DataSource to invoke
41 // |SendResponse| between the time when there are no more refs and the time
42 // when the object is deleted.
43 return;
44 }
45 BrowserThread::PostTask(
46 BrowserThread::IO, FROM_HERE,
47 base::Bind(&URLDataSourceImpl::SendResponseOnIOThread, this, request_id,
48 bytes_ptr));
49 }
50
51 void URLDataSourceImpl::SendResponseOnIOThread(
52 int request_id,
53 scoped_refptr<base::RefCountedMemory> bytes) {
54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
55 if (backend_)
56 backend_->DataAvailable(request_id, bytes);
57 }
58
59 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/webui/url_data_source_impl.h ('k') | content/browser/webui/web_ui_data_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698