OLD | NEW |
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 "device/test/usb_test_gadget.h" | 5 #include "device/test/usb_test_gadget.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 {UsbTestGadget::KEYBOARD, "/keyboard/configure", 0x58F1}, | 59 {UsbTestGadget::KEYBOARD, "/keyboard/configure", 0x58F1}, |
60 {UsbTestGadget::MOUSE, "/mouse/configure", 0x58F2}, | 60 {UsbTestGadget::MOUSE, "/mouse/configure", 0x58F2}, |
61 {UsbTestGadget::HID_ECHO, "/hid_echo/configure", 0x58F3}, | 61 {UsbTestGadget::HID_ECHO, "/hid_echo/configure", 0x58F3}, |
62 {UsbTestGadget::ECHO, "/echo/configure", 0x58F4}, | 62 {UsbTestGadget::ECHO, "/echo/configure", 0x58F4}, |
63 }; | 63 }; |
64 | 64 |
65 class UsbTestGadgetImpl : public UsbTestGadget { | 65 class UsbTestGadgetImpl : public UsbTestGadget { |
66 public: | 66 public: |
67 virtual ~UsbTestGadgetImpl(); | 67 virtual ~UsbTestGadgetImpl(); |
68 | 68 |
69 virtual bool Unclaim() OVERRIDE; | 69 virtual bool Unclaim() override; |
70 virtual bool Disconnect() OVERRIDE; | 70 virtual bool Disconnect() override; |
71 virtual bool Reconnect() OVERRIDE; | 71 virtual bool Reconnect() override; |
72 virtual bool SetType(Type type) OVERRIDE; | 72 virtual bool SetType(Type type) override; |
73 virtual UsbDevice* GetDevice() const OVERRIDE; | 73 virtual UsbDevice* GetDevice() const override; |
74 virtual std::string GetSerialNumber() const OVERRIDE; | 74 virtual std::string GetSerialNumber() const override; |
75 | 75 |
76 protected: | 76 protected: |
77 UsbTestGadgetImpl(); | 77 UsbTestGadgetImpl(); |
78 | 78 |
79 private: | 79 private: |
80 scoped_ptr<net::URLFetcher> CreateURLFetcher( | 80 scoped_ptr<net::URLFetcher> CreateURLFetcher( |
81 const GURL& url, | 81 const GURL& url, |
82 net::URLFetcher::RequestType request_type, | 82 net::URLFetcher::RequestType request_type, |
83 net::URLFetcherDelegate* delegate); | 83 net::URLFetcherDelegate* delegate); |
84 int SimplePOSTRequest(const GURL& url, const std::string& form_data); | 84 int SimplePOSTRequest(const GURL& url, const std::string& form_data); |
85 bool FindUnclaimed(); | 85 bool FindUnclaimed(); |
86 bool GetVersion(std::string* version); | 86 bool GetVersion(std::string* version); |
87 bool Update(); | 87 bool Update(); |
88 bool FindClaimed(); | 88 bool FindClaimed(); |
89 bool ReadLocalVersion(std::string* version); | 89 bool ReadLocalVersion(std::string* version); |
90 bool ReadLocalPackage(std::string* package); | 90 bool ReadLocalPackage(std::string* package); |
91 bool ReadFile(const base::FilePath& file_path, std::string* content); | 91 bool ReadFile(const base::FilePath& file_path, std::string* content); |
92 | 92 |
93 class Delegate : public net::URLFetcherDelegate { | 93 class Delegate : public net::URLFetcherDelegate { |
94 public: | 94 public: |
95 Delegate() {} | 95 Delegate() {} |
96 virtual ~Delegate() {} | 96 virtual ~Delegate() {} |
97 | 97 |
98 void WaitForCompletion() { | 98 void WaitForCompletion() { |
99 run_loop_.Run(); | 99 run_loop_.Run(); |
100 } | 100 } |
101 | 101 |
102 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE { | 102 virtual void OnURLFetchComplete(const net::URLFetcher* source) override { |
103 run_loop_.Quit(); | 103 run_loop_.Quit(); |
104 } | 104 } |
105 | 105 |
106 private: | 106 private: |
107 base::RunLoop run_loop_; | 107 base::RunLoop run_loop_; |
108 | 108 |
109 DISALLOW_COPY_AND_ASSIGN(Delegate); | 109 DISALLOW_COPY_AND_ASSIGN(Delegate); |
110 }; | 110 }; |
111 | 111 |
112 scoped_refptr<UsbDevice> device_; | 112 scoped_refptr<UsbDevice> device_; |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 } | 514 } |
515 PlatformThread::Sleep(TimeDelta::FromMilliseconds(kRetryPeriod)); | 515 PlatformThread::Sleep(TimeDelta::FromMilliseconds(kRetryPeriod)); |
516 } | 516 } |
517 VLOG(1) << "It took " << (kDisconnectRetries - retries) | 517 VLOG(1) << "It took " << (kDisconnectRetries - retries) |
518 << " retries for the device to reconnect."; | 518 << " retries for the device to reconnect."; |
519 | 519 |
520 return true; | 520 return true; |
521 } | 521 } |
522 | 522 |
523 } // namespace device | 523 } // namespace device |
OLD | NEW |