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

Side by Side Diff: chrome/browser/ui/webui/workers_ui.cc

Issue 7397021: Re-land r93365 - add RefCountedString (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 9 years, 5 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/ui/webui/theme_source.h ('k') | content/renderer/render_widget_browsertest.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) 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/ui/webui/workers_ui.h" 5 #include "chrome/browser/ui/webui/workers_ui.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/memory/ref_counted_memory.h" 8 #include "base/memory/ref_counted_memory.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 worker_data->SetString(kUrlField, i->url().spec()); 94 worker_data->SetString(kUrlField, i->url().spec());
95 worker_data->SetString(kNameField, i->name()); 95 worker_data->SetString(kNameField, i->name());
96 worker_data->SetInteger(kPidField, worker->pid()); 96 worker_data->SetInteger(kPidField, worker->pid());
97 workers_list.Append(worker_data); 97 workers_list.Append(worker_data);
98 } 98 }
99 } 99 }
100 100
101 std::string json_string; 101 std::string json_string;
102 base::JSONWriter::Write(&workers_list, false, &json_string); 102 base::JSONWriter::Write(&workers_list, false, &json_string);
103 103
104 scoped_refptr<RefCountedBytes> json_bytes(new RefCountedBytes()); 104 SendResponse(request_id, base::RefCountedString::TakeString(&json_string));
105 json_bytes->data.resize(json_string.size());
106 std::copy(json_string.begin(), json_string.end(), json_bytes->data.begin());
107
108 SendResponse(request_id, json_bytes);
109 } 105 }
110 106
111 class WorkersDOMHandler : public WebUIMessageHandler { 107 class WorkersDOMHandler : public WebUIMessageHandler {
112 public: 108 public:
113 WorkersDOMHandler() {} 109 WorkersDOMHandler() {}
114 virtual ~WorkersDOMHandler() {} 110 virtual ~WorkersDOMHandler() {}
115 111
116 private: 112 private:
117 // WebUIMessageHandler implementation. 113 // WebUIMessageHandler implementation.
118 virtual void RegisterMessages(); 114 virtual void RegisterMessages();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 WorkersUI::WorkersUI(TabContents* contents) : ChromeWebUI(contents) { 150 WorkersUI::WorkersUI(TabContents* contents) : ChromeWebUI(contents) {
155 WorkersDOMHandler* handler = new WorkersDOMHandler(); 151 WorkersDOMHandler* handler = new WorkersDOMHandler();
156 AddMessageHandler(handler); 152 AddMessageHandler(handler);
157 handler->Attach(this); 153 handler->Attach(this);
158 154
159 WorkersUIHTMLSource* html_source = new WorkersUIHTMLSource(); 155 WorkersUIHTMLSource* html_source = new WorkersUIHTMLSource();
160 156
161 // Set up the chrome://workers/ source. 157 // Set up the chrome://workers/ source.
162 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); 158 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source);
163 } 159 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/theme_source.h ('k') | content/renderer/render_widget_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698