Chromium Code Reviews| 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 #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 Loading... | |
| 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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 |
| 639 // ExtensionFunction: | 635 // ExtensionFunction: |
| 640 void SetError(const std::string& error) override; | 636 void SetError(const std::string& error); |
|
lazyboy
2016/10/03 20:34:01
Same here.
Devlin
2016/10/03 23:07:50
Done.
| |
| 641 const std::string& GetError() const override; | 637 const std::string& GetError() const override; |
| 642 | 638 |
| 643 protected: | 639 protected: |
| 644 ~AsyncExtensionFunction() override; | 640 ~AsyncExtensionFunction() override; |
| 645 | 641 |
| 646 // Sets a single Value as the results of the function. | 642 // Sets a single Value as the results of the function. |
| 647 void SetResult(std::unique_ptr<base::Value> result); | 643 void SetResult(std::unique_ptr<base::Value> result); |
| 648 | 644 |
| 649 // Sets multiple Values as the results of the function. | 645 // Sets multiple Values as the results of the function. |
| 650 void SetResultList(std::unique_ptr<base::ListValue> results); | 646 void SetResultList(std::unique_ptr<base::ListValue> results); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 674 private: | 670 private: |
| 675 // If you're hitting a compile error here due to "final" - great! You're | 671 // 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 | 672 // doing the right thing, you just need to extend UIThreadExtensionFunction |
| 677 // instead of AsyncExtensionFunction. | 673 // instead of AsyncExtensionFunction. |
| 678 ResponseAction Run() final; | 674 ResponseAction Run() final; |
| 679 | 675 |
| 680 DISALLOW_COPY_AND_ASSIGN(AsyncExtensionFunction); | 676 DISALLOW_COPY_AND_ASSIGN(AsyncExtensionFunction); |
| 681 }; | 677 }; |
| 682 | 678 |
| 683 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ | 679 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ |
| OLD | NEW |