+class GetTokensState : public NSSOperationState {
+ public:
+ explicit GetTokensState(const GetTokensCallback& callback);
+ virtual ~GetTokensState() {}
+
+ virtual void OnError(const tracked_objects::Location& from,
+ const std::string& error_message) OVERRIDE {
+ CallBack(from,
+ scoped_ptr<std::vector<std::string> >() /* no token ids */,
+ error_message);
+ }
+
+ void CallBack(const tracked_objects::Location& from,
+ scoped_ptr<std::vector<std::string> > token_ids,
+ const std::string& error_message) {
+ origin_task_runner_->PostTask(
+ from, base::Bind(callback_, base::Passed(&token_ids), error_message));
+ }
+
+ private:
+ // Must be called on origin thread, therefore use CallBack().
+ GetTokensCallback callback_;
+};
+