Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: extensions/browser/extension_function.h

Issue 2386823002: [Extensions] Remove ExtensionFunction::SetError() (Closed)
Patch Set: lazyboy's Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_
6 #define EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ 6 #define EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <list> 10 #include <list>
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // Specifies the raw arguments to the function, as a JSON value. 236 // Specifies the raw arguments to the function, as a JSON value.
237 // TODO(dcheng): This should take a const ref. 237 // TODO(dcheng): This should take a const ref.
238 virtual void SetArgs(const base::ListValue* args); 238 virtual void SetArgs(const base::ListValue* args);
239 239
240 // Retrieves the results of the function as a ListValue. 240 // Retrieves the results of the function as a ListValue.
241 const base::ListValue* GetResultList() const; 241 const base::ListValue* GetResultList() const;
242 242
243 // Retrieves any error string from the function. 243 // Retrieves any error string from the function.
244 virtual const std::string& GetError() const; 244 virtual const std::string& GetError() const;
245 245
246 // Sets the function's error string.
247 // TODO(devlin): This should be handled exclusively through the responses.
248 virtual void SetError(const std::string& error);
249
250 bool bad_message() const { return bad_message_; } 246 bool bad_message() const { return bad_message_; }
251 void set_bad_message(bool bad_message) { bad_message_ = bad_message; } 247 void set_bad_message(bool bad_message) { bad_message_ = bad_message; }
252 248
253 // Specifies the name of the function. A long-lived string (such as a string 249 // Specifies the name of the function. A long-lived string (such as a string
254 // literal) must be provided. 250 // literal) must be provided.
255 void set_name(const char* name) { name_ = name; } 251 void set_name(const char* name) { name_ = name; }
256 const char* name() const { return name_; } 252 const char* name() const { return name_; }
257 253
258 void set_profile_id(void* profile_id) { profile_id_ = profile_id; } 254 void set_profile_id(void* profile_id) { profile_id_ = profile_id; }
259 void* profile_id() const { return profile_id_; } 255 void* profile_id() const { return profile_id_; }
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 625
630 DISALLOW_COPY_AND_ASSIGN(IOThreadExtensionFunction); 626 DISALLOW_COPY_AND_ASSIGN(IOThreadExtensionFunction);
631 }; 627 };
632 628
633 // Base class for an extension function that runs asynchronously *relative to 629 // Base class for an extension function that runs asynchronously *relative to
634 // the browser's UI thread*. 630 // the browser's UI thread*.
635 class AsyncExtensionFunction : public UIThreadExtensionFunction { 631 class AsyncExtensionFunction : public UIThreadExtensionFunction {
636 public: 632 public:
637 AsyncExtensionFunction(); 633 AsyncExtensionFunction();
638 634
635 void SetError(const std::string& error);
636
639 // ExtensionFunction: 637 // ExtensionFunction:
640 void SetError(const std::string& error) override;
641 const std::string& GetError() const override; 638 const std::string& GetError() const override;
642 639
643 protected: 640 protected:
644 ~AsyncExtensionFunction() override; 641 ~AsyncExtensionFunction() override;
645 642
646 // Sets a single Value as the results of the function. 643 // Sets a single Value as the results of the function.
647 void SetResult(std::unique_ptr<base::Value> result); 644 void SetResult(std::unique_ptr<base::Value> result);
648 645
649 // Sets multiple Values as the results of the function. 646 // Sets multiple Values as the results of the function.
650 void SetResultList(std::unique_ptr<base::ListValue> results); 647 void SetResultList(std::unique_ptr<base::ListValue> results);
(...skipping 23 matching lines...) Expand all
674 private: 671 private:
675 // If you're hitting a compile error here due to "final" - great! You're 672 // If you're hitting a compile error here due to "final" - great! You're
676 // doing the right thing, you just need to extend UIThreadExtensionFunction 673 // doing the right thing, you just need to extend UIThreadExtensionFunction
677 // instead of AsyncExtensionFunction. 674 // instead of AsyncExtensionFunction.
678 ResponseAction Run() final; 675 ResponseAction Run() final;
679 676
680 DISALLOW_COPY_AND_ASSIGN(AsyncExtensionFunction); 677 DISALLOW_COPY_AND_ASSIGN(AsyncExtensionFunction);
681 }; 678 };
682 679
683 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ 680 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/input_ime/background.js ('k') | extensions/browser/extension_function.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698