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

Unified Diff: net/socket_stream/socket_stream_job_manager.cc

Issue 601077: Support HttpOnly cookie on Web Socket (Closed)
Patch Set: fix darin's comment Created 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/socket_stream/socket_stream_job_manager.h ('k') | net/websockets/websocket_job.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket_stream/socket_stream_job_manager.cc
diff --git a/net/socket_stream/socket_stream_job_manager.cc b/net/socket_stream/socket_stream_job_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7dd0d6bbb76c1bc9016ed645c3bfbb2d94ac0e27
--- /dev/null
+++ b/net/socket_stream/socket_stream_job_manager.cc
@@ -0,0 +1,59 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/socket_stream/socket_stream_job_manager.h"
+
+namespace net {
+
+SocketStreamJobManager::SocketStreamJobManager() {
+}
+
+SocketStreamJobManager::~SocketStreamJobManager() {
+}
+
+SocketStreamJob* SocketStreamJobManager::CreateJob(
+ const GURL& url, SocketStream::Delegate* delegate) const {
+ // If url is invalid, create plain SocketStreamJob, which will close
+ // the socket immediately.
+ if (!url.is_valid()) {
+ SocketStreamJob* job = new SocketStreamJob();
+ job->InitSocketStream(new SocketStream(url, delegate));
+ return job;
+ }
+
+ const std::string& scheme = url.scheme(); // already lowercase
+
+ AutoLock locked(lock_);
+ FactoryMap::const_iterator found = factories_.find(scheme);
+ if (found != factories_.end()) {
+ SocketStreamJob* job = found->second(url, delegate);
+ if (job)
+ return job;
+ }
+ SocketStreamJob* job = new SocketStreamJob();
+ job->InitSocketStream(new SocketStream(url, delegate));
+ return job;
+}
+
+SocketStreamJob::ProtocolFactory*
+SocketStreamJobManager::RegisterProtocolFactory(
+ const std::string& scheme, SocketStreamJob::ProtocolFactory* factory) {
+ AutoLock locked(lock_);
+
+ SocketStreamJob::ProtocolFactory* old_factory;
+ FactoryMap::iterator found = factories_.find(scheme);
+ if (found != factories_.end()) {
+ old_factory = found->second;
+ } else {
+ old_factory = NULL;
+ }
+ if (factory) {
+ factories_[scheme] = factory;
+ } else if (found != factories_.end()) {
+ factories_.erase(found);
+ }
+ return old_factory;
+}
+
+} // namespace net
« no previous file with comments | « net/socket_stream/socket_stream_job_manager.h ('k') | net/websockets/websocket_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698