Commit 95c9a411 authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Minor revision to spell_check_host_chrome_impl_mac.cc

1. Removed two members stored in SpellingRequest; Changed them as passed
   via call stack. Note: |SpellingRequest::text_| doesn't need to be
   stored, either; However, it still seems natural to store it.

2. Added more comments to SpellingRequest.

Change-Id: I64a07a8e1fe9b23bf5dd0757d225f309548da05b
Reviewed-on: https://chromium-review.googlesource.com/956617Reviewed-by: default avatarRachel Blum <groby@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542038}
parent 07a5fbb4
...@@ -68,10 +68,11 @@ class SpellingRequest { ...@@ -68,10 +68,11 @@ class SpellingRequest {
private: private:
// Request server-side checking for |text_|. // Request server-side checking for |text_|.
void RequestRemoteCheck(SpellingServiceClient* client); void RequestRemoteCheck(SpellingServiceClient* client,
const service_manager::Identity& renderer_identity);
// Request a check for |text_| from local spell checker. // Request a check for |text_| from local spell checker.
void RequestLocalCheck(); void RequestLocalCheck(int document_tag);
// Check if all pending requests are done, send reply to render process if so. // Check if all pending requests are done, send reply to render process if so.
void OnCheckCompleted(); void OnCheckCompleted();
...@@ -96,11 +97,13 @@ class SpellingRequest { ...@@ -96,11 +97,13 @@ class SpellingRequest {
base::RepeatingClosure completion_barrier_; base::RepeatingClosure completion_barrier_;
bool remote_success_; bool remote_success_;
// The string to be spell-checked.
base::string16 text_; base::string16 text_;
const service_manager::Identity renderer_identity_;
int document_tag_; // Callback to send the results to renderer.
RequestTextCheckCallback callback_; RequestTextCheckCallback callback_;
// Callback to delete |this|. Called on |this| after everything is done.
DestructionCallback destruction_callback_; DestructionCallback destruction_callback_;
base::WeakPtrFactory<SpellingRequest> weak_factory_; base::WeakPtrFactory<SpellingRequest> weak_factory_;
...@@ -115,8 +118,6 @@ SpellingRequest::SpellingRequest( ...@@ -115,8 +118,6 @@ SpellingRequest::SpellingRequest(
DestructionCallback destruction_callback) DestructionCallback destruction_callback)
: remote_success_(false), : remote_success_(false),
text_(text), text_(text),
renderer_identity_(renderer_identity),
document_tag_(document_tag),
callback_(std::move(callback)), callback_(std::move(callback)),
destruction_callback_(std::move(destruction_callback)), destruction_callback_(std::move(destruction_callback)),
weak_factory_(this) { weak_factory_(this) {
...@@ -126,14 +127,16 @@ SpellingRequest::SpellingRequest( ...@@ -126,14 +127,16 @@ SpellingRequest::SpellingRequest(
completion_barrier_ = completion_barrier_ =
BarrierClosure(2, base::BindOnce(&SpellingRequest::OnCheckCompleted, BarrierClosure(2, base::BindOnce(&SpellingRequest::OnCheckCompleted,
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
RequestRemoteCheck(client); RequestRemoteCheck(client, renderer_identity);
RequestLocalCheck(); RequestLocalCheck(document_tag);
} }
void SpellingRequest::RequestRemoteCheck(SpellingServiceClient* client) { void SpellingRequest::RequestRemoteCheck(
SpellingServiceClient* client,
const service_manager::Identity& renderer_identity) {
BrowserContext* context = NULL; BrowserContext* context = NULL;
content::RenderProcessHost* host = content::RenderProcessHost* host =
content::RenderProcessHost::FromRendererIdentity(renderer_identity_); content::RenderProcessHost::FromRendererIdentity(renderer_identity);
if (host) if (host)
context = host->GetBrowserContext(); context = host->GetBrowserContext();
...@@ -144,10 +147,10 @@ void SpellingRequest::RequestRemoteCheck(SpellingServiceClient* client) { ...@@ -144,10 +147,10 @@ void SpellingRequest::RequestRemoteCheck(SpellingServiceClient* client) {
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
} }
void SpellingRequest::RequestLocalCheck() { void SpellingRequest::RequestLocalCheck(int document_tag) {
// |this| may be gone at callback invocation if the owner has been removed. // |this| may be gone at callback invocation if the owner has been removed.
spellcheck_platform::RequestTextCheck( spellcheck_platform::RequestTextCheck(
document_tag_, text_, document_tag, text_,
base::BindOnce(&SpellingRequest::OnLocalCheckCompletedOnAnyThread, base::BindOnce(&SpellingRequest::OnLocalCheckCompletedOnAnyThread,
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment