Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: content/browser/nfc/nfc_host.cc

Issue 2865653002: [Device Service] Decouple NFC implementation from //content (Closed)
Patch Set: Response to reviews Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/nfc/nfc_host.h"
6
7 #include <utility>
8
9 #include "base/atomic_sequence_num.h"
10 #include "content/public/common/service_manager_connection.h"
11 #include "device/nfc/nfc.mojom.h"
12 #include "jni/NfcHost_jni.h"
13 #include "services/device/public/interfaces/constants.mojom.h"
14 #include "services/service_manager/public/cpp/connector.h"
15
16 namespace content {
17
18 namespace {
19
20 base::StaticAtomicSequenceNumber g_unique_id;
21
22 } // namespace
23
24 NFCHost::NFCHost(WebContents* web_contents)
25 : id_(g_unique_id.GetNext()), web_contents_(web_contents) {
26 DCHECK(web_contents_);
27
28 JNIEnv* env = base::android::AttachCurrentThread();
29 java_nfc_host_.Reset(
30 Java_NfcHost_create(env, web_contents_->GetJavaWebContents().obj(), id_));
31
32 if (ServiceManagerConnection::GetForProcess()) {
33 service_manager::Connector* connector =
34 ServiceManagerConnection::GetForProcess()->GetConnector();
35 connector->BindInterface(device::mojom::kServiceName,
36 mojo::MakeRequest(&nfc_provider_));
37 }
38 }
39
40 void NFCHost::GetNFC(device::nfc::mojom::NFCRequest request) {
41 // Connect to an NFC object, associating it with |id_|.
42 nfc_provider_->GetNFCForHost(id_, std::move(request));
43 }
44
45 NFCHost::~NFCHost() {}
46
47 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698