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

Side by Side Diff: media/midi/usb_midi_device_factory_android.cc

Issue 1915443003: Replace scoped_ptr with std::unique_ptr in //media. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptr-media-base
Patch Set: scopedptr-media: rebase Created 4 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
« no previous file with comments | « media/midi/usb_midi_device_android.h ('k') | media/midi/usb_midi_input_stream_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/midi/usb_midi_device_factory_android.h" 5 #include "media/midi/usb_midi_device_factory_android.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/android/context_utils.h" 9 #include "base/android/context_utils.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/memory/ptr_util.h"
13 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
14 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
15 #include "jni/UsbMidiDeviceFactoryAndroid_jni.h" 16 #include "jni/UsbMidiDeviceFactoryAndroid_jni.h"
16 #include "media/midi/usb_midi_device_android.h" 17 #include "media/midi/usb_midi_device_android.h"
17 18
18 namespace media { 19 namespace media {
19 namespace midi { 20 namespace midi {
20 21
21 namespace { 22 namespace {
22 23
23 typedef UsbMidiDevice::Factory::Callback Callback; 24 using Callback = UsbMidiDevice::Factory::Callback;
24 25
25 } // namespace 26 } // namespace
26 27
27 UsbMidiDeviceFactoryAndroid::UsbMidiDeviceFactoryAndroid() : delegate_(NULL) {} 28 UsbMidiDeviceFactoryAndroid::UsbMidiDeviceFactoryAndroid() : delegate_(NULL) {}
28 29
29 UsbMidiDeviceFactoryAndroid::~UsbMidiDeviceFactoryAndroid() { 30 UsbMidiDeviceFactoryAndroid::~UsbMidiDeviceFactoryAndroid() {
30 JNIEnv* env = base::android::AttachCurrentThread(); 31 JNIEnv* env = base::android::AttachCurrentThread();
31 if (!raw_factory_.is_null()) 32 if (!raw_factory_.is_null())
32 Java_UsbMidiDeviceFactoryAndroid_close( 33 Java_UsbMidiDeviceFactoryAndroid_close(
33 env, raw_factory_.obj(), base::android::GetApplicationContext()); 34 env, raw_factory_.obj(), base::android::GetApplicationContext());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 71
71 callback_.Run(true, &devices_to_pass); 72 callback_.Run(true, &devices_to_pass);
72 } 73 }
73 74
74 // Called from the Java world. 75 // Called from the Java world.
75 void UsbMidiDeviceFactoryAndroid::OnUsbMidiDeviceAttached( 76 void UsbMidiDeviceFactoryAndroid::OnUsbMidiDeviceAttached(
76 JNIEnv* env, 77 JNIEnv* env,
77 const JavaParamRef<jobject>& caller, 78 const JavaParamRef<jobject>& caller,
78 const JavaParamRef<jobject>& device) { 79 const JavaParamRef<jobject>& device) {
79 delegate_->OnDeviceAttached( 80 delegate_->OnDeviceAttached(
80 scoped_ptr<UsbMidiDevice>(new UsbMidiDeviceAndroid(device, delegate_))); 81 base::WrapUnique(new UsbMidiDeviceAndroid(device, delegate_)));
81 } 82 }
82 83
83 // Called from the Java world. 84 // Called from the Java world.
84 void UsbMidiDeviceFactoryAndroid::OnUsbMidiDeviceDetached( 85 void UsbMidiDeviceFactoryAndroid::OnUsbMidiDeviceDetached(
85 JNIEnv* env, 86 JNIEnv* env,
86 const JavaParamRef<jobject>& caller, 87 const JavaParamRef<jobject>& caller,
87 jint index) { 88 jint index) {
88 delegate_->OnDeviceDetached(index); 89 delegate_->OnDeviceDetached(index);
89 } 90 }
90 91
91 bool UsbMidiDeviceFactoryAndroid::RegisterUsbMidiDeviceFactory(JNIEnv* env) { 92 bool UsbMidiDeviceFactoryAndroid::RegisterUsbMidiDeviceFactory(JNIEnv* env) {
92 return RegisterNativesImpl(env); 93 return RegisterNativesImpl(env);
93 } 94 }
94 95
95 } // namespace midi 96 } // namespace midi
96 } // namespace media 97 } // namespace media
OLDNEW
« no previous file with comments | « media/midi/usb_midi_device_android.h ('k') | media/midi/usb_midi_input_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698