forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
input-tools: connect vk to handwriting gestures
This CL adds the necessary mojo plumbing to connect the vk extension to the handwriting service gesture based model. Bug: 1076172 Change-Id: I968e2b3b103c9cf84a358874323fc218809a7e84 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2262373 Commit-Queue: Curtis McMullan <curtismcmullan@chromium.org> Reviewed-by: Andrew Moylan <amoylan@chromium.org> Reviewed-by: Sam McNally <sammc@chromium.org> Reviewed-by: David Vallet <dvallet@chromium.org> Reviewed-by: Darren Shen <shend@chromium.org> Cr-Commit-Position: refs/heads/master@{#784730}
- Loading branch information
1 parent
d2d3b90
commit 9836a23
Showing
6 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
chromeos/services/machine_learning/public/cpp/handwriting_recognizer_manager.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2020 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chromeos/services/machine_learning/public/cpp/handwriting_recognizer_manager.h" | ||
|
||
#include "base/no_destructor.h" | ||
#include "chromeos/services/machine_learning/public/cpp/service_connection.h" | ||
#include "chromeos/services/machine_learning/public/mojom/handwriting_recognizer.mojom.h" | ||
#include "chromeos/services/machine_learning/public/mojom/handwriting_recognizer_requestor.mojom.h" | ||
|
||
namespace chromeos { | ||
namespace machine_learning { | ||
|
||
HandwritingRecognizerManager::HandwritingRecognizerManager() = default; | ||
|
||
HandwritingRecognizerManager::~HandwritingRecognizerManager() = default; | ||
|
||
HandwritingRecognizerManager* HandwritingRecognizerManager::GetInstance() { | ||
static base::NoDestructor<HandwritingRecognizerManager> manager; | ||
return manager.get(); | ||
} | ||
|
||
void HandwritingRecognizerManager::AddReceiver( | ||
mojo::PendingReceiver<mojom::HandwritingRecognizerRequestor> receiver) { | ||
receivers_.Add(this, std::move(receiver)); | ||
} | ||
|
||
void HandwritingRecognizerManager::LoadHandwritingModel( | ||
mojo::PendingReceiver<mojom::HandwritingRecognizer> receiver, | ||
LoadHandwritingModelCallback callback) { | ||
ServiceConnection::GetInstance()->LoadHandwritingModelWithSpec( | ||
mojom::HandwritingRecognizerSpec::New("en"), std::move(receiver), | ||
std::move(callback)); | ||
} | ||
|
||
void HandwritingRecognizerManager::LoadGestureModel( | ||
mojo::PendingReceiver<mojom::HandwritingRecognizer> receiver, | ||
LoadHandwritingModelCallback callback) { | ||
ServiceConnection::GetInstance()->LoadHandwritingModelWithSpec( | ||
mojom::HandwritingRecognizerSpec::New("gesture_in_context"), | ||
std::move(receiver), std::move(callback)); | ||
} | ||
|
||
} // namespace machine_learning | ||
} // namespace chromeos |
46 changes: 46 additions & 0 deletions
46
chromeos/services/machine_learning/public/cpp/handwriting_recognizer_manager.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2020 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CHROMEOS_SERVICES_MACHINE_LEARNING_PUBLIC_CPP_HANDWRITING_RECOGNIZER_MANAGER_H_ | ||
#define CHROMEOS_SERVICES_MACHINE_LEARNING_PUBLIC_CPP_HANDWRITING_RECOGNIZER_MANAGER_H_ | ||
|
||
#include "chromeos/services/machine_learning/public/mojom/handwriting_recognizer_requestor.mojom.h" | ||
#include "mojo/public/cpp/bindings/pending_receiver.h" | ||
#include "mojo/public/cpp/bindings/receiver_set.h" | ||
|
||
namespace chromeos { | ||
namespace machine_learning { | ||
|
||
// TODO(916760): This class is a temporary fix until the work in crbug/916760 | ||
// is completed. Once completed this class should be removed, along with | ||
// mojom::HandwritingRecognizerRequestor. | ||
class HandwritingRecognizerManager | ||
: public mojom::HandwritingRecognizerRequestor { | ||
public: | ||
HandwritingRecognizerManager(); | ||
~HandwritingRecognizerManager() override; | ||
|
||
static HandwritingRecognizerManager* GetInstance(); | ||
|
||
void AddReceiver( | ||
mojo::PendingReceiver<mojom::HandwritingRecognizerRequestor> receiver); | ||
|
||
private: | ||
void LoadGestureModel( | ||
mojo::PendingReceiver<mojom::HandwritingRecognizer> receiver, | ||
LoadHandwritingModelCallback callback) override; | ||
|
||
void LoadHandwritingModel( | ||
mojo::PendingReceiver<mojom::HandwritingRecognizer> receiver, | ||
LoadHandwritingModelCallback callback) override; | ||
|
||
mojo::ReceiverSet<mojom::HandwritingRecognizerRequestor> receivers_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(HandwritingRecognizerManager); | ||
}; | ||
|
||
} // namespace machine_learning | ||
} // namespace chromeos | ||
|
||
#endif // CHROMEOS_SERVICES_MACHINE_LEARNING_PUBLIC_CPP_HANDWRITING_RECOGNIZER_MANAGER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
chromeos/services/machine_learning/public/mojom/handwriting_recognizer_requestor.mojom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2020 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
module chromeos.machine_learning.mojom; | ||
|
||
import "chromeos/services/machine_learning/public/mojom/handwriting_recognizer.mojom"; | ||
import "chromeos/services/machine_learning/public/mojom/machine_learning_service.mojom"; | ||
import "chromeos/services/machine_learning/public/mojom/model.mojom"; | ||
|
||
// Provides an interface to load a gesture or handwriting recognizer model. This | ||
// is only used for communication between extensions and the machine learning | ||
// service. | ||
// | ||
// TODO(916760): This interface is temporary. Once the work is completed in | ||
// crbug/916760, we should look at removing this interface and any client uses | ||
// of it. | ||
// | ||
interface HandwritingRecognizerRequestor { | ||
// Load a gesture based handwriting recognizer, and connect it to the | ||
// given pending receiver. | ||
LoadGestureModel(pending_receiver<HandwritingRecognizer> receiver) | ||
=> (LoadModelResult result); | ||
|
||
// Load a text based handwriting recognizer, and connect it to the | ||
// given pending receiver. | ||
LoadHandwritingModel(pending_receiver<HandwritingRecognizer> receiver) | ||
=> (LoadModelResult result); | ||
}; |