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

Side by Side Diff: chrome/browser/extensions/api/streams_private/streams_private_api.cc

Issue 281513003: Implement chrome.streamsPrivate.abort() extensions function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 "chrome/browser/extensions/api/streams_private/streams_private_api.h" 5 #include "chrome/browser/extensions/api/streams_private/streams_private_api.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/extensions/extension_tab_util.h" 9 #include "chrome/browser/extensions/extension_tab_util.h"
10 #include "chrome/common/extensions/api/streams_private.h" 10 #include "chrome/common/extensions/api/streams_private.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 new Event(streams_private::OnExecuteMimeTypeHandler::kEventName, 81 new Event(streams_private::OnExecuteMimeTypeHandler::kEventName,
82 streams_private::OnExecuteMimeTypeHandler::Create(info))); 82 streams_private::OnExecuteMimeTypeHandler::Create(info)));
83 83
84 EventRouter::Get(browser_context_) 84 EventRouter::Get(browser_context_)
85 ->DispatchEventToExtension(extension_id, event.Pass()); 85 ->DispatchEventToExtension(extension_id, event.Pass());
86 86
87 GURL url = stream->GetURL(); 87 GURL url = stream->GetURL();
88 streams_[extension_id][url] = make_linked_ptr(stream.release()); 88 streams_[extension_id][url] = make_linked_ptr(stream.release());
89 } 89 }
90 90
91 void StreamsPrivateAPI::AbortStream(const std::string& extension_id,
92 const GURL& stream_url) {
93 StreamMap::iterator it = streams_.find(extension_id);
94 if (it != streams_.end())
95 it->second.erase(stream_url);
96 }
97
91 void StreamsPrivateAPI::OnExtensionUnloaded( 98 void StreamsPrivateAPI::OnExtensionUnloaded(
92 content::BrowserContext* browser_context, 99 content::BrowserContext* browser_context,
93 const Extension* extension, 100 const Extension* extension,
94 UnloadedExtensionInfo::Reason reason) { 101 UnloadedExtensionInfo::Reason reason) {
95 streams_.erase(extension->id()); 102 streams_.erase(extension->id());
96 } 103 }
97 104
105 StreamsPrivateAbortFunction::StreamsPrivateAbortFunction() {
106 }
107
108 bool StreamsPrivateAbortFunction::Prepare() {
109 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &stream_url_));
110 StreamsPrivateAPI::Get(browser_context())->AbortStream(extension_id(),
111 GURL(stream_url_));
112 return true;
113 }
114
115 bool StreamsPrivateAbortFunction::Respond() {
116 return true;
117 }
118
98 static base::LazyInstance<BrowserContextKeyedAPIFactory<StreamsPrivateAPI> > 119 static base::LazyInstance<BrowserContextKeyedAPIFactory<StreamsPrivateAPI> >
99 g_factory = LAZY_INSTANCE_INITIALIZER; 120 g_factory = LAZY_INSTANCE_INITIALIZER;
100 121
101 // static 122 // static
102 BrowserContextKeyedAPIFactory<StreamsPrivateAPI>* 123 BrowserContextKeyedAPIFactory<StreamsPrivateAPI>*
103 StreamsPrivateAPI::GetFactoryInstance() { 124 StreamsPrivateAPI::GetFactoryInstance() {
104 return g_factory.Pointer(); 125 return g_factory.Pointer();
105 } 126 }
106 127
107 } // namespace extensions 128 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698