diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/extensions/extension_function.cc | 6 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_function.h | 5 |
2 files changed, 7 insertions, 4 deletions
diff --git a/chrome/browser/extensions/extension_function.cc b/chrome/browser/extensions/extension_function.cc index f74fdb9..a846d96 100644 --- a/chrome/browser/extensions/extension_function.cc +++ b/chrome/browser/extensions/extension_function.cc @@ -10,7 +10,7 @@ #include "chrome/browser/extensions/extension_function_dispatcher.h" void AsyncExtensionFunction::SetArgs(const std::string& args) { - DCHECK(!args_); // should only be called once + DCHECK(!args_); // Should only be called once. if (!args.empty()) { JSONReader reader; args_ = reader.JsonToValue(args, false, false); @@ -26,7 +26,9 @@ void AsyncExtensionFunction::SetArgs(const std::string& args) { const std::string AsyncExtensionFunction::GetResult() { std::string json; - JSONWriter::Write(result_.get(), false, &json); + // Some functions might not need to return any results. + if (result_.get()) + JSONWriter::Write(result_.get(), false, &json); return json; } diff --git a/chrome/browser/extensions/extension_function.h b/chrome/browser/extensions/extension_function.h index cbe85b9..5d0ddb0 100644 --- a/chrome/browser/extensions/extension_function.h +++ b/chrome/browser/extensions/extension_function.h @@ -28,6 +28,7 @@ class Profile; class ExtensionFunction { public: ExtensionFunction() : request_id_(-1), has_callback_(false) {} + virtual ~ExtensionFunction() {} // Specifies the name of the function. virtual void SetName(const std::string& name) { } @@ -79,7 +80,7 @@ class ExtensionFunction { // parsing JSON (and instead uses custom serialization of Value objects). class AsyncExtensionFunction : public ExtensionFunction { public: - AsyncExtensionFunction() : bad_message_(false) {} + AsyncExtensionFunction() : args_(NULL), bad_message_(false) {} virtual ~AsyncExtensionFunction() {} virtual void SetArgs(const std::string& args); @@ -94,7 +95,7 @@ class AsyncExtensionFunction : public ExtensionFunction { Profile* profile(); - // The arguments to the API. Only non-null if argument were specfied. + // The arguments to the API. Only non-null if argument were specified. Value* args_; // The result of the API. This should be populated by the derived class before |