OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 22 matching lines...) Expand all Loading... |
33 | 33 |
34 AsyncExtensionFunction::AsyncExtensionFunction() | 34 AsyncExtensionFunction::AsyncExtensionFunction() |
35 : args_(NULL), bad_message_(false) { | 35 : args_(NULL), bad_message_(false) { |
36 } | 36 } |
37 | 37 |
38 AsyncExtensionFunction::~AsyncExtensionFunction() { | 38 AsyncExtensionFunction::~AsyncExtensionFunction() { |
39 } | 39 } |
40 | 40 |
41 void AsyncExtensionFunction::SetArgs(const ListValue* args) { | 41 void AsyncExtensionFunction::SetArgs(const ListValue* args) { |
42 DCHECK(!args_.get()); // Should only be called once. | 42 DCHECK(!args_.get()); // Should only be called once. |
43 args_.reset(static_cast<ListValue*>(args->DeepCopy())); | 43 args_.reset(args->DeepCopy()); |
44 } | 44 } |
45 | 45 |
46 const std::string AsyncExtensionFunction::GetResult() { | 46 const std::string AsyncExtensionFunction::GetResult() { |
47 std::string json; | 47 std::string json; |
48 // Some functions might not need to return any results. | 48 // Some functions might not need to return any results. |
49 if (result_.get()) | 49 if (result_.get()) |
50 base::JSONWriter::Write(result_.get(), false, &json); | 50 base::JSONWriter::Write(result_.get(), false, &json); |
51 return json; | 51 return json; |
52 } | 52 } |
53 | 53 |
(...skipping 23 matching lines...) Expand all Loading... |
77 | 77 |
78 SyncExtensionFunction::SyncExtensionFunction() { | 78 SyncExtensionFunction::SyncExtensionFunction() { |
79 } | 79 } |
80 | 80 |
81 SyncExtensionFunction::~SyncExtensionFunction() { | 81 SyncExtensionFunction::~SyncExtensionFunction() { |
82 } | 82 } |
83 | 83 |
84 void SyncExtensionFunction::Run() { | 84 void SyncExtensionFunction::Run() { |
85 SendResponse(RunImpl()); | 85 SendResponse(RunImpl()); |
86 } | 86 } |
OLD | NEW |