OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/extensions/extension_web_socket_proxy_private_api.h" | 5 #include "chrome/browser/extensions/extension_web_socket_proxy_private_api.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "chrome/browser/internal_auth.h" | 10 #include "chrome/browser/internal_auth.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 map["extension_id"] = extension_id(); | 52 map["extension_id"] = extension_id(); |
53 StringValue* passport = Value::CreateStringValue( | 53 StringValue* passport = Value::CreateStringValue( |
54 browser::InternalAuthGeneration::GeneratePassport( | 54 browser::InternalAuthGeneration::GeneratePassport( |
55 "web_socket_proxy", map)); | 55 "web_socket_proxy", map)); |
56 result_.reset(passport); | 56 result_.reset(passport); |
57 } | 57 } |
58 #endif // defined(OS_CHROMEOS) | 58 #endif // defined(OS_CHROMEOS) |
59 | 59 |
60 if (delay_response) { | 60 if (delay_response) { |
61 const int kTimeout = 3; | 61 const int kTimeout = 3; |
62 timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(kTimeout), | 62 timer_.Start(base::TimeDelta::FromSeconds(kTimeout), |
63 this, &WebSocketProxyPrivateGetPassportForTCPFunction::Finalize); | 63 this, &WebSocketProxyPrivateGetPassportForTCPFunction::Finalize); |
64 } else { | 64 } else { |
65 Finalize(); | 65 Finalize(); |
66 } | 66 } |
67 return true; | 67 return true; |
68 } | 68 } |
69 | 69 |
70 void WebSocketProxyPrivateGetPassportForTCPFunction::Observe( | 70 void WebSocketProxyPrivateGetPassportForTCPFunction::Observe( |
71 int type, const NotificationSource& source, | 71 int type, const NotificationSource& source, |
72 const NotificationDetails& details) { | 72 const NotificationDetails& details) { |
73 #if defined(OS_CHROMEOS) | 73 #if defined(OS_CHROMEOS) |
74 DCHECK(type == chrome::NOTIFICATION_WEB_SOCKET_PROXY_STARTED); | 74 DCHECK(type == chrome::NOTIFICATION_WEB_SOCKET_PROXY_STARTED); |
75 #else | 75 #else |
76 NOTREACHED(); | 76 NOTREACHED(); |
77 #endif | 77 #endif |
78 timer_.Stop(); // Cancel timeout timer. | 78 timer_.Stop(); // Cancel timeout timer. |
79 Finalize(); | 79 Finalize(); |
80 } | 80 } |
81 | 81 |
82 void WebSocketProxyPrivateGetPassportForTCPFunction::Finalize() { | 82 void WebSocketProxyPrivateGetPassportForTCPFunction::Finalize() { |
83 if (is_finalized_) { | 83 if (is_finalized_) { |
84 NOTREACHED(); | 84 NOTREACHED(); |
85 return; | 85 return; |
86 } | 86 } |
87 is_finalized_ = true; | 87 is_finalized_ = true; |
88 SendResponse(true); | 88 SendResponse(true); |
89 Release(); | 89 Release(); |
90 } | 90 } |
91 | 91 |
OLD | NEW |