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

Side by Side Diff: remoting/base/util.cc

Issue 209323002: New policies: enable/disable relay; port range (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/base/util.h" 5 #include "remoting/base/util.h"
6 6
7 #include <limits.h>
7 #include <math.h> 8 #include <math.h>
9 #include <stdlib.h>
8 10
9 #include "base/logging.h" 11 #include "base/logging.h"
10 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
11 #include "base/time/time.h" 13 #include "base/time/time.h"
12 #include "media/base/video_frame.h" 14 #include "media/base/video_frame.h"
13 #include "media/base/yuv_convert.h" 15 #include "media/base/yuv_convert.h"
14 #include "third_party/libyuv/include/libyuv/convert.h" 16 #include "third_party/libyuv/include/libyuv/convert.h"
15 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" 17 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
16 18
17 using media::VideoFrame; 19 using media::VideoFrame;
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 return true; 309 return true;
308 } 310 }
309 311
310 bool DoesRectContain(const webrtc::DesktopRect& a, 312 bool DoesRectContain(const webrtc::DesktopRect& a,
311 const webrtc::DesktopRect& b) { 313 const webrtc::DesktopRect& b) {
312 webrtc::DesktopRect intersection(a); 314 webrtc::DesktopRect intersection(a);
313 intersection.IntersectWith(b); 315 intersection.IntersectWith(b);
314 return intersection.equals(b); 316 return intersection.equals(b);
315 } 317 }
316 318
319 bool ParsePortRange(const std::string& port_range, int* out_min_port,
320 int* out_max_port) {
321 size_t separator_index = port_range.find('-');
322 if (separator_index == std::string::npos)
323 return false;
324
325 int min_port = atoi(port_range.substr(0, separator_index).c_str());
326 int max_port = atoi(port_range.substr(separator_index + 1).c_str());
327
328 if (min_port <= 0 || min_port > max_port || max_port > USHRT_MAX)
329 return false;
330
331 *out_min_port = min_port;
332 *out_max_port = max_port;
333 return true;
334 }
335
317 } // namespace remoting 336 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698