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

Side by Side Diff: extensions/browser/api/serial/serial_api.cc

Issue 873903002: Set serial connection parameters immediately on connect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
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 "extensions/browser/api/serial/serial_api.h" 5 #include "extensions/browser/api/serial/serial_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 123
124 serial_event_dispatcher_ = SerialEventDispatcher::Get(browser_context()); 124 serial_event_dispatcher_ = SerialEventDispatcher::Get(browser_context());
125 DCHECK(serial_event_dispatcher_); 125 DCHECK(serial_event_dispatcher_);
126 126
127 return true; 127 return true;
128 } 128 }
129 129
130 void SerialConnectFunction::AsyncWorkStart() { 130 void SerialConnectFunction::AsyncWorkStart() {
131 DCHECK_CURRENTLY_ON(BrowserThread::IO); 131 DCHECK_CURRENTLY_ON(BrowserThread::IO);
132 connection_ = CreateSerialConnection(params_->path, extension_->id()); 132 connection_ = CreateSerialConnection(params_->path, extension_->id());
133 connection_->Open(base::Bind(&SerialConnectFunction::OnConnected, this)); 133 connection_->Open(*params_->options.get(),
134 base::Bind(&SerialConnectFunction::OnConnected, this));
134 } 135 }
135 136
136 void SerialConnectFunction::OnConnected(bool success) { 137 void SerialConnectFunction::OnConnected(bool success) {
137 DCHECK(connection_); 138 DCHECK(connection_);
138 139
139 if (success) { 140 if (!success) {
140 if (!connection_->Configure(*params_->options.get())) {
141 delete connection_;
142 connection_ = NULL;
143 }
144 } else {
145 delete connection_; 141 delete connection_;
146 connection_ = NULL; 142 connection_ = NULL;
147 } 143 }
148 144
149 BrowserThread::PostTask( 145 BrowserThread::PostTask(
150 BrowserThread::IO, 146 BrowserThread::IO,
151 FROM_HERE, 147 FROM_HERE,
152 base::Bind(&SerialConnectFunction::FinishConnect, this)); 148 base::Bind(&SerialConnectFunction::FinishConnect, this));
153 } 149 }
154 150
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 if (device->has_vendor_id) 439 if (device->has_vendor_id)
444 info->vendor_id.reset(new int(static_cast<int>(device->vendor_id))); 440 info->vendor_id.reset(new int(static_cast<int>(device->vendor_id)));
445 if (device->has_product_id) 441 if (device->has_product_id)
446 info->product_id.reset(new int(static_cast<int>(device->product_id))); 442 info->product_id.reset(new int(static_cast<int>(device->product_id)));
447 if (device->display_name) 443 if (device->display_name)
448 info->display_name.reset(new std::string(device->display_name)); 444 info->display_name.reset(new std::string(device->display_name));
449 return info; 445 return info;
450 } 446 }
451 447
452 } // namespace mojo 448 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698