// Copyright 2012 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_SPELLCHECK_BROWSER_SPELLING_SERVICE_CLIENT_H_ #define COMPONENTS_SPELLCHECK_BROWSER_SPELLING_SERVICE_CLIENT_H_ #include <list> #include <memory> #include <string> #include <vector> #include "base/compiler_specific.h" #include "base/functional/callback.h" #include "net/traffic_annotation/network_traffic_annotation.h" #include "url/gurl.h" struct SpellCheckResult; namespace base { class TimeTicks; } namespace content { class BrowserContext; } namespace network { class SharedURLLoaderFactory; class SimpleURLLoader; } // namespace network // A class that encapsulates a JSON-RPC call to the Spelling service to check // text there. This class creates a JSON-RPC request, sends the request to the // service with URLFetcher, parses a response from the service, and calls a // provided callback method. When a user deletes this object before it finishes // a JSON-RPC call, this class cancels the JSON-RPC call without calling the // callback method. A simple usage is creating a SpellingServiceClient and // calling its RequestTextCheck method as listed in the following snippet. // // class MyClient { // public: // MyClient(); // virtual ~MyClient(); // // void OnTextCheckComplete( // int tag, // bool success, // const std::vector<SpellCheckResult>& results) { // ... // } // // void MyTextCheck(BrowserContext* context, const std::u16string& text) { // client_.reset(new SpellingServiceClient); // client_->RequestTextCheck(context, 0, text, // base::BindOnce(&MyClient::OnTextCheckComplete, // base::Unretained(this)); // } // private: // std::unique_ptr<SpellingServiceClient> client_; // }; // class SpellingServiceClient { … }; #endif // COMPONENTS_SPELLCHECK_BROWSER_SPELLING_SERVICE_CLIENT_H_