| OLD | NEW |
| 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 } |
| OLD | NEW |