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

Side by Side Diff: chrome/browser/extensions/extension_web_socket_proxy_private_api.cc

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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) 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 22 matching lines...) Expand all
33 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &hostname)); 33 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &hostname));
34 int port = -1; 34 int port = -1;
35 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, &port)); 35 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, &port));
36 36
37 if (chromeos::WebSocketProxyController::CheckCredentials( 37 if (chromeos::WebSocketProxyController::CheckCredentials(
38 extension_id(), hostname, port, 38 extension_id(), hostname, port,
39 chromeos::WebSocketProxyController::PLAIN_TCP)) { 39 chromeos::WebSocketProxyController::PLAIN_TCP)) {
40 if (!chromeos::WebSocketProxyController::IsInitiated()) { 40 if (!chromeos::WebSocketProxyController::IsInitiated()) {
41 delay_response = true; 41 delay_response = true;
42 registrar_.Add( 42 registrar_.Add(
43 this, NotificationType::WEB_SOCKET_PROXY_STARTED, 43 this, chrome::WEB_SOCKET_PROXY_STARTED,
44 NotificationService::AllSources()); 44 NotificationService::AllSources());
45 chromeos::WebSocketProxyController::Initiate(); 45 chromeos::WebSocketProxyController::Initiate();
46 } 46 }
47 47
48 std::map<std::string, std::string> map; 48 std::map<std::string, std::string> map;
49 map["hostname"] = hostname; 49 map["hostname"] = hostname;
50 map["port"] = base::IntToString(port); 50 map["port"] = base::IntToString(port);
51 map["extension_id"] = extension_id(); 51 map["extension_id"] = extension_id();
52 StringValue* passport = Value::CreateStringValue( 52 StringValue* passport = Value::CreateStringValue(
53 browser::InternalAuthGeneration::GeneratePassport( 53 browser::InternalAuthGeneration::GeneratePassport(
54 "web_socket_proxy", map)); 54 "web_socket_proxy", map));
55 result_.reset(passport); 55 result_.reset(passport);
56 } 56 }
57 #endif // defined(OS_CHROMEOS) 57 #endif // defined(OS_CHROMEOS)
58 58
59 if (delay_response) { 59 if (delay_response) {
60 const int kTimeout = 3; 60 const int kTimeout = 3;
61 timer_.Start(base::TimeDelta::FromSeconds(kTimeout), 61 timer_.Start(base::TimeDelta::FromSeconds(kTimeout),
62 this, &WebSocketProxyPrivateGetPassportForTCPFunction::Finalize); 62 this, &WebSocketProxyPrivateGetPassportForTCPFunction::Finalize);
63 } else { 63 } else {
64 Finalize(); 64 Finalize();
65 } 65 }
66 return true; 66 return true;
67 } 67 }
68 68
69 void WebSocketProxyPrivateGetPassportForTCPFunction::Observe( 69 void WebSocketProxyPrivateGetPassportForTCPFunction::Observe(
70 NotificationType type, const NotificationSource& source, 70 int type, const NotificationSource& source,
71 const NotificationDetails& details) { 71 const NotificationDetails& details) {
72 #if defined(OS_CHROMEOS) 72 #if defined(OS_CHROMEOS)
73 DCHECK(type.value == NotificationType::WEB_SOCKET_PROXY_STARTED); 73 DCHECK(type == chrome::WEB_SOCKET_PROXY_STARTED);
74 #else 74 #else
75 NOTREACHED(); 75 NOTREACHED();
76 #endif 76 #endif
77 timer_.Stop(); // Cancel timeout timer. 77 timer_.Stop(); // Cancel timeout timer.
78 Finalize(); 78 Finalize();
79 } 79 }
80 80
81 void WebSocketProxyPrivateGetPassportForTCPFunction::Finalize() { 81 void WebSocketProxyPrivateGetPassportForTCPFunction::Finalize() {
82 if (is_finalized_) { 82 if (is_finalized_) {
83 NOTREACHED(); 83 NOTREACHED();
84 return; 84 return;
85 } 85 }
86 is_finalized_ = true; 86 is_finalized_ = true;
87 SendResponse(true); 87 SendResponse(true);
88 Release(); 88 Release();
89 } 89 }
90 90
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698