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

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

Issue 2865653002: [Device Service] Decouple NFC implementation from //content (Closed)
Patch Set: Response to review + fix for tests that don't actually run on bots 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 "base/atomic_sequence_num.h"
8 #include "content/public/common/service_manager_connection.h"
9 #include "device/nfc/nfc.mojom.h"
10 #include "services/device/public/interfaces/constants.mojom.h"
11 #include "services/service_manager/public/cpp/connector.h"
12
13 #if defined(OS_ANDROID)
14 #include "jni/NfcHost_jni.h"
15 #endif
16
17 namespace content {
18
19 namespace {
20
21 base::StaticAtomicSequenceNumber g_unique_id;
22
23 } // namespace
24
25 NFCHost::NFCHost(WebContents* web_contents)
26 : id_(g_unique_id.GetNext()), web_contents_(web_contents) {
27 DCHECK(web_contents_);
28
29 #if defined(OS_ANDROID)
30 JNIEnv* env = base::android::AttachCurrentThread();
31 java_nfc_host_.Reset(
32 Java_NfcHost_create(env, web_contents_->GetJavaWebContents().obj(), id_));
33
34 if (ServiceManagerConnection::GetForProcess()) {
35 service_manager::Connector* connector =
36 ServiceManagerConnection::GetForProcess()->GetConnector();
37 DCHECK(connector);
jam 2017/05/09 15:11:16 nit: since the pointer is used in the next line, t
blundell 2017/05/10 13:15:25 Done.
38 connector->BindInterface(device::mojom::kServiceName,
39 mojo::MakeRequest(&nfc_provider_));
40 }
41 #endif
42 }
43
44 void NFCHost::GetNFC(device::nfc::mojom::NFCRequest request) {
45 #if defined(OS_ANDROID)
46 // Connect to an NFC object, associating it with |id_|.
47 nfc_provider_->GetNFCForHost(id_, std::move(request));
dcheng 2017/05/10 06:20:18 Nit: #include <utility>
blundell 2017/05/10 13:15:25 Done.
48 #endif
49 }
50
51 NFCHost::~NFCHost() {}
52
53 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/nfc/nfc_host.h ('k') | content/browser/service_manager/service_manager_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698