| 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/extensions/extension_function.h" | 5 #include "chrome/browser/extensions/extension_function.h" |
| 6 | 6 |
| 7 #include "base/json/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 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 void ExtensionFunction::SetArgs(const ListValue* args) { | 88 void ExtensionFunction::SetArgs(const ListValue* args) { |
| 89 DCHECK(!args_.get()); // Should only be called once. | 89 DCHECK(!args_.get()); // Should only be called once. |
| 90 args_.reset(args->DeepCopy()); | 90 args_.reset(args->DeepCopy()); |
| 91 } | 91 } |
| 92 | 92 |
| 93 const std::string ExtensionFunction::GetResult() { | 93 const std::string ExtensionFunction::GetResult() { |
| 94 std::string json; | 94 std::string json; |
| 95 // Some functions might not need to return any results. | 95 // Some functions might not need to return any results. |
| 96 if (result_.get()) | 96 if (result_.get()) |
| 97 base::JSONWriter::Write(result_.get(), false, &json); | 97 base::JSONWriter::Write(result_.get(), &json); |
| 98 return json; | 98 return json; |
| 99 } | 99 } |
| 100 | 100 |
| 101 Value* ExtensionFunction::GetResultValue() { | 101 Value* ExtensionFunction::GetResultValue() { |
| 102 return result_.get(); | 102 return result_.get(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 const std::string ExtensionFunction::GetError() { | 105 const std::string ExtensionFunction::GetError() { |
| 106 return error_; | 106 return error_; |
| 107 } | 107 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 | 237 |
| 238 SyncIOThreadExtensionFunction::SyncIOThreadExtensionFunction() { | 238 SyncIOThreadExtensionFunction::SyncIOThreadExtensionFunction() { |
| 239 } | 239 } |
| 240 | 240 |
| 241 SyncIOThreadExtensionFunction::~SyncIOThreadExtensionFunction() { | 241 SyncIOThreadExtensionFunction::~SyncIOThreadExtensionFunction() { |
| 242 } | 242 } |
| 243 | 243 |
| 244 void SyncIOThreadExtensionFunction::Run() { | 244 void SyncIOThreadExtensionFunction::Run() { |
| 245 SendResponse(RunImpl()); | 245 SendResponse(RunImpl()); |
| 246 } | 246 } |
| OLD | NEW |