OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "extensions/browser/extension_function.h" | 5 #include "extensions/browser/extension_function.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 return availability.is_available(); | 249 return availability.is_available(); |
250 } | 250 } |
251 | 251 |
252 void ExtensionFunction::OnQuotaExceeded(const std::string& violation_error) { | 252 void ExtensionFunction::OnQuotaExceeded(const std::string& violation_error) { |
253 error_ = violation_error; | 253 error_ = violation_error; |
254 SendResponse(false); | 254 SendResponse(false); |
255 } | 255 } |
256 | 256 |
257 void ExtensionFunction::SetArgs(const base::ListValue* args) { | 257 void ExtensionFunction::SetArgs(const base::ListValue* args) { |
258 DCHECK(!args_.get()); // Should only be called once. | 258 DCHECK(!args_.get()); // Should only be called once. |
259 args_.reset(args->DeepCopy()); | 259 args_ = args->CreateDeepCopy(); |
260 } | |
261 | |
262 void ExtensionFunction::SetResult(base::Value* result) { | |
263 results_.reset(new base::ListValue()); | |
264 results_->Append(result); | |
265 } | 260 } |
266 | 261 |
267 void ExtensionFunction::SetResult(std::unique_ptr<base::Value> result) { | 262 void ExtensionFunction::SetResult(std::unique_ptr<base::Value> result) { |
268 results_.reset(new base::ListValue()); | 263 results_.reset(new base::ListValue()); |
269 results_->Append(std::move(result)); | 264 results_->Append(std::move(result)); |
270 } | 265 } |
271 | 266 |
272 void ExtensionFunction::SetResultList( | 267 void ExtensionFunction::SetResultList( |
273 std::unique_ptr<base::ListValue> results) { | 268 std::unique_ptr<base::ListValue> results) { |
274 results_ = std::move(results); | 269 results_ = std::move(results); |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 ExtensionFunction::ResponseAction SyncIOThreadExtensionFunction::Run() { | 569 ExtensionFunction::ResponseAction SyncIOThreadExtensionFunction::Run() { |
575 return RespondNow(RunSync() ? ArgumentList(std::move(results_)) | 570 return RespondNow(RunSync() ? ArgumentList(std::move(results_)) |
576 : Error(error_)); | 571 : Error(error_)); |
577 } | 572 } |
578 | 573 |
579 // static | 574 // static |
580 bool SyncIOThreadExtensionFunction::ValidationFailure( | 575 bool SyncIOThreadExtensionFunction::ValidationFailure( |
581 SyncIOThreadExtensionFunction* function) { | 576 SyncIOThreadExtensionFunction* function) { |
582 return false; | 577 return false; |
583 } | 578 } |
OLD | NEW |