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

Side by Side Diff: device/vr/android/gvr/gvr_gamepad_data_fetcher.cc

Issue 2471433002: Implement WebVR presentation pausing for VR Shell Menu Mode (Closed)
Patch Set: Address Comments Created 4 years, 1 month 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
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 "device/vr/android/gvr/gvr_gamepad_data_fetcher.h" 5 #include "device/vr/android/gvr/gvr_gamepad_data_fetcher.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 8
9 #include "device/vr/android/gvr/gvr_delegate.h" 9 #include "device/vr/android/gvr/gvr_delegate.h"
10 #include "third_party/WebKit/public/platform/WebGamepads.h" 10 #include "third_party/WebKit/public/platform/WebGamepads.h"
(...skipping 10 matching lines...) Expand all
21 21
22 const size_t str_to_copy = std::min(src.size(), dest_length - 1); 22 const size_t str_to_copy = std::min(src.size(), dest_length - 1);
23 memcpy(dest, src.data(), str_to_copy * sizeof(base::string16::value_type)); 23 memcpy(dest, src.data(), str_to_copy * sizeof(base::string16::value_type));
24 dest[str_to_copy] = 0; 24 dest[str_to_copy] = 0;
25 } 25 }
26 26
27 } // namespace 27 } // namespace
28 28
29 using namespace blink; 29 using namespace blink;
30 30
31 GvrGamepadDataFetcher::Factory::Factory(GvrDelegate* delegate, 31 GvrGamepadDataFetcher::Factory::Factory(base::WeakPtr<GvrDelegate> delegate,
32 unsigned int display_id) 32 unsigned int display_id)
33 : delegate_(delegate), display_id_(display_id) {} 33 : delegate_(delegate), display_id_(display_id) {}
34 34
35 GvrGamepadDataFetcher::Factory::~Factory() {} 35 GvrGamepadDataFetcher::Factory::~Factory() {}
36 36
37 std::unique_ptr<GamepadDataFetcher> 37 std::unique_ptr<GamepadDataFetcher>
38 GvrGamepadDataFetcher::Factory::CreateDataFetcher() { 38 GvrGamepadDataFetcher::Factory::CreateDataFetcher() {
39 if (!delegate_)
40 return std::unique_ptr<GamepadDataFetcher>(nullptr);
dcheng 2016/11/12 02:03:31 Nit: Just return nullptr_ should be sufficient her
mthiesse 2016/11/14 16:41:38 Done.
39 return std::unique_ptr<GamepadDataFetcher>( 41 return std::unique_ptr<GamepadDataFetcher>(
40 new GvrGamepadDataFetcher(delegate_, display_id_)); 42 new GvrGamepadDataFetcher(delegate_.get(), display_id_));
41 } 43 }
42 44
43 GamepadSource GvrGamepadDataFetcher::Factory::source() { 45 GamepadSource GvrGamepadDataFetcher::Factory::source() {
44 return GAMEPAD_SOURCE_GVR; 46 return GAMEPAD_SOURCE_GVR;
45 } 47 }
46 48
47 GvrGamepadDataFetcher::GvrGamepadDataFetcher(GvrDelegate* delegate, 49 GvrGamepadDataFetcher::GvrGamepadDataFetcher(GvrDelegate* delegate,
48 unsigned int display_id) 50 unsigned int display_id)
49 : display_id_(display_id) { 51 : display_id_(display_id) {
50 gvr::GvrApi* gvr_api = delegate->gvr_api(); 52 gvr::GvrApi* gvr_api = delegate->gvr_api();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 return; 145 return;
144 146
145 if (paused) { 147 if (paused) {
146 controller_api_->Pause(); 148 controller_api_->Pause();
147 } else { 149 } else {
148 controller_api_->Resume(); 150 controller_api_->Resume();
149 } 151 }
150 } 152 }
151 153
152 } // namespace device 154 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698