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

Side by Side Diff: chrome/browser/extensions/extension_function.cc

Issue 316016: Move the json-related files into a separate json directory. This hopefully al... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/extensions/extension_function.h" 5 #include "chrome/browser/extensions/extension_function.h"
6 6
7 #include "base/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "chrome/browser/extensions/extension_function_dispatcher.h" 9 #include "chrome/browser/extensions/extension_function_dispatcher.h"
10 10
11 void AsyncExtensionFunction::SetArgs(const Value* args) { 11 void AsyncExtensionFunction::SetArgs(const Value* args) {
12 DCHECK(!args_); // Should only be called once. 12 DCHECK(!args_); // Should only be called once.
13 args_ = args->DeepCopy(); 13 args_ = args->DeepCopy();
14 } 14 }
15 15
16 const std::string AsyncExtensionFunction::GetResult() { 16 const std::string AsyncExtensionFunction::GetResult() {
17 std::string json; 17 std::string json;
18 // Some functions might not need to return any results. 18 // Some functions might not need to return any results.
19 if (result_.get()) 19 if (result_.get())
20 JSONWriter::Write(result_.get(), false, &json); 20 base::JSONWriter::Write(result_.get(), false, &json);
21 return json; 21 return json;
22 } 22 }
23 23
24 void AsyncExtensionFunction::SendResponse(bool success) { 24 void AsyncExtensionFunction::SendResponse(bool success) {
25 if (!dispatcher()) 25 if (!dispatcher())
26 return; 26 return;
27 if (bad_message_) { 27 if (bad_message_) {
28 dispatcher()->HandleBadMessage(this); 28 dispatcher()->HandleBadMessage(this);
29 } else { 29 } else {
30 dispatcher()->SendResponse(this, success); 30 dispatcher()->SendResponse(this, success);
31 } 31 }
32 } 32 }
33 33
34 std::string AsyncExtensionFunction::extension_id() { 34 std::string AsyncExtensionFunction::extension_id() {
35 DCHECK(dispatcher()); 35 DCHECK(dispatcher());
36 return dispatcher()->extension_id(); 36 return dispatcher()->extension_id();
37 } 37 }
38 38
39 Profile* AsyncExtensionFunction::profile() { 39 Profile* AsyncExtensionFunction::profile() {
40 DCHECK(dispatcher()); 40 DCHECK(dispatcher());
41 return dispatcher()->profile(); 41 return dispatcher()->profile();
42 } 42 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_browser_event_router.cc ('k') | chrome/browser/extensions/extension_message_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698