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

Side by Side Diff: remoting/client/jni/jni_display_handler.cc

Issue 2230193002: remoting: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 4 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 | « remoting/base/buffered_socket_writer.cc ('k') | remoting/codec/audio_decoder_opus.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "remoting/client/jni/jni_display_handler.h" 5 #include "remoting/client/jni/jni_display_handler.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 95 }
96 96
97 void JniDisplayHandler::SetCursorShape( 97 void JniDisplayHandler::SetCursorShape(
98 const protocol::CursorShapeInfo& cursor_shape) { 98 const protocol::CursorShapeInfo& cursor_shape) {
99 DCHECK(runtime_->display_task_runner()->BelongsToCurrentThread()); 99 DCHECK(runtime_->display_task_runner()->BelongsToCurrentThread());
100 100
101 // const_cast<> is safe as long as the Java updateCursorShape() method copies 101 // const_cast<> is safe as long as the Java updateCursorShape() method copies
102 // the data out of the buffer without mutating it, and doesn't keep any 102 // the data out of the buffer without mutating it, and doesn't keep any
103 // reference to the buffer afterwards. Unfortunately, there seems to be no way 103 // reference to the buffer afterwards. Unfortunately, there seems to be no way
104 // to create a read-only ByteBuffer from a pointer-to-const. 104 // to create a read-only ByteBuffer from a pointer-to-const.
105 char* data = string_as_array(const_cast<std::string*>(&cursor_shape.data())); 105 char* data =
106 base::string_as_array(const_cast<std::string*>(&cursor_shape.data()));
106 int cursor_total_bytes = 107 int cursor_total_bytes =
107 cursor_shape.width() * cursor_shape.height() * kBytesPerPixel; 108 cursor_shape.width() * cursor_shape.height() * kBytesPerPixel;
108 109
109 JNIEnv* env = base::android::AttachCurrentThread(); 110 JNIEnv* env = base::android::AttachCurrentThread();
110 base::android::ScopedJavaLocalRef<jobject> buffer( 111 base::android::ScopedJavaLocalRef<jobject> buffer(
111 env, env->NewDirectByteBuffer(data, cursor_total_bytes)); 112 env, env->NewDirectByteBuffer(data, cursor_total_bytes));
112 Java_Display_updateCursorShape( 113 Java_Display_updateCursorShape(
113 env, java_display_.obj(), cursor_shape.width(), cursor_shape.height(), 114 env, java_display_.obj(), cursor_shape.width(), cursor_shape.height(),
114 cursor_shape.hotspot_x(), cursor_shape.hotspot_y(), buffer.obj()); 115 cursor_shape.hotspot_x(), cursor_shape.hotspot_y(), buffer.obj());
115 } 116 }
116 117
117 } // namespace remoting 118 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/base/buffered_socket_writer.cc ('k') | remoting/codec/audio_decoder_opus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698