From 5a8e52252663ff442d5164df0e00ca8445b0aa45 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Mon, 27 Feb 2017 12:44:43 +0530 Subject: [PATCH] StreamManager class is no longer required. Stream lifetime is managed by webui --- atom/browser/atom_browser_context.cc | 2 - atom/browser/atom_browser_context.h | 3 - .../atom_resource_dispatcher_host_delegate.cc | 1 - atom/browser/stream_manager.cc | 66 ------------------- atom/browser/stream_manager.h | 66 ------------------- atom/browser/ui/webui/pdf_viewer_ui.cc | 2 +- filenames.gypi | 2 - 7 files changed, 1 insertion(+), 141 deletions(-) delete mode 100644 atom/browser/stream_manager.cc delete mode 100644 atom/browser/stream_manager.h diff --git a/atom/browser/atom_browser_context.cc b/atom/browser/atom_browser_context.cc index 2167f3973585..76a23cdcda4e 100644 --- a/atom/browser/atom_browser_context.cc +++ b/atom/browser/atom_browser_context.cc @@ -17,7 +17,6 @@ #include "atom/browser/net/atom_network_delegate.h" #include "atom/browser/net/atom_url_request_job_factory.h" #include "atom/browser/net/http_protocol_handler.h" -#include "atom/browser/stream_manager.h" #include "atom/browser/web_view_manager.h" #include "atom/common/atom_version.h" #include "atom/common/chrome_version.h" @@ -74,7 +73,6 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition, const base::DictionaryValue& options) : brightray::BrowserContext(partition, in_memory), ct_delegate_(new AtomCTDelegate), - stream_manager_(new StreamManager), network_delegate_(new AtomNetworkDelegate), cookie_delegate_(new AtomCookieDelegate) { // Construct user agent string. diff --git a/atom/browser/atom_browser_context.h b/atom/browser/atom_browser_context.h index 87aa92c4fc1c..340c8f46626f 100644 --- a/atom/browser/atom_browser_context.h +++ b/atom/browser/atom_browser_context.h @@ -19,7 +19,6 @@ class AtomCTDelegate; class AtomDownloadManagerDelegate; class AtomNetworkDelegate; class AtomPermissionManager; -class StreamManager; class WebViewManager; class AtomBrowserContext : public brightray::BrowserContext { @@ -59,7 +58,6 @@ class AtomBrowserContext : public brightray::BrowserContext { AtomCookieDelegate* cookie_delegate() const { return cookie_delegate_.get(); } - StreamManager* stream_manager() const { return stream_manager_.get(); } protected: AtomBrowserContext(const std::string& partition, bool in_memory, @@ -72,7 +70,6 @@ class AtomBrowserContext : public brightray::BrowserContext { std::unique_ptr permission_manager_; std::unique_ptr blob_reader_; std::unique_ptr ct_delegate_; - std::unique_ptr stream_manager_; std::string user_agent_; bool use_cache_; diff --git a/atom/browser/atom_resource_dispatcher_host_delegate.cc b/atom/browser/atom_resource_dispatcher_host_delegate.cc index d533ec34f5ba..341c76589d94 100644 --- a/atom/browser/atom_resource_dispatcher_host_delegate.cc +++ b/atom/browser/atom_resource_dispatcher_host_delegate.cc @@ -75,7 +75,6 @@ void OnPdfStreamCreated(const GURL& original_url, content::NavigationController::LoadURLParams params( GURL(base::StringPrintf("%sindex.html?%s=%s", kPdfViewerUIOrigin, kPdfPluginSrc, original_url.spec().c_str()))); - params.can_load_local_resources = true; web_contents->GetController().LoadURLWithParams(params); } diff --git a/atom/browser/stream_manager.cc b/atom/browser/stream_manager.cc deleted file mode 100644 index 4ca1d2287159..000000000000 --- a/atom/browser/stream_manager.cc +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2017 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#include "atom/browser/stream_manager.h" - -#include "base/memory/ptr_util.h" -#include "content/public/browser/navigation_handle.h" -#include "content/public/browser/render_frame_host.h" -#include "content/public/browser/render_process_host.h" -#include "content/public/browser/web_contents.h" - -namespace atom { - -StreamManager::StreamManager() {} - -StreamManager::~StreamManager() {} - -void StreamManager::AddStream(std::unique_ptr stream, - const std::string& stream_id, - int render_process_id, - int render_frame_id) { - streams_.insert(std::make_pair(stream_id, std::move(stream))); - observers_[stream_id] = base::MakeUnique( - this, stream_id, render_process_id, render_frame_id); -} - -std::unique_ptr StreamManager::ReleaseStream( - const std::string& stream_id) { - auto stream = streams_.find(stream_id); - if (stream == streams_.end()) - return nullptr; - - std::unique_ptr result = - base::WrapUnique(stream->second.release()); - streams_.erase(stream); - observers_.erase(stream_id); - return result; -} - -StreamManager::EmbedderObserver::EmbedderObserver(StreamManager* stream_manager, - const std::string& stream_id, - int render_process_id, - int render_frame_id) - : stream_manager_(stream_manager), stream_id_(stream_id) { - content::WebContents* web_contents = - content::WebContents::FromRenderFrameHost( - content::RenderFrameHost::FromID(render_process_id, render_frame_id)); - content::WebContentsObserver::Observe(web_contents); -} - -void StreamManager::EmbedderObserver::RenderProcessGone( - base::TerminationStatus status) { - AbortStream(); -} - -void StreamManager::EmbedderObserver::WebContentsDestroyed() { - AbortStream(); -} - -void StreamManager::EmbedderObserver::AbortStream() { - Observe(nullptr); - stream_manager_->ReleaseStream(stream_id_); -} - -} // namespace atom diff --git a/atom/browser/stream_manager.h b/atom/browser/stream_manager.h deleted file mode 100644 index 7a1471d1a409..000000000000 --- a/atom/browser/stream_manager.h +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2017 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#ifndef ATOM_BROWSER_STREAM_MANAGER_H_ -#define ATOM_BROWSER_STREAM_MANAGER_H_ - -#include -#include - -#include "base/macros.h" -#include "content/public/browser/stream_info.h" -#include "content/public/browser/web_contents_observer.h" - -namespace atom { - -// A container for streams that have not been claimed by associated -// WebContents. -class StreamManager { - public: - StreamManager(); - ~StreamManager(); - - void AddStream(std::unique_ptr stream, - const std::string& stream_id, - int render_process_id, - int render_frame_id); - - std::unique_ptr ReleaseStream( - const std::string& stream_id); - - private: - // WebContents observer that deletes an unclaimed stream - // associated with it, when destroyed. - class EmbedderObserver : public content::WebContentsObserver { - public: - EmbedderObserver(StreamManager* stream_manager, - const std::string& stream_id, - int render_process_id, - int render_frame_id); - - private: - // content::WebContentsObserver: - void RenderProcessGone(base::TerminationStatus status) override; - void WebContentsDestroyed() override; - - void AbortStream(); - - StreamManager* stream_manager_; - std::string stream_id_; - - DISALLOW_COPY_AND_ASSIGN(EmbedderObserver); - }; - - // StreamID => Stream. - std::map> streams_; - - // StreamID => WebContents Observer. - std::map> observers_; - - DISALLOW_COPY_AND_ASSIGN(StreamManager); -}; - -} // namespace atom - -#endif // ATOM_BROWSER_STREAM_MANAGER_H_ diff --git a/atom/browser/ui/webui/pdf_viewer_ui.cc b/atom/browser/ui/webui/pdf_viewer_ui.cc index d937d5ee25f7..080447e63da6 100644 --- a/atom/browser/ui/webui/pdf_viewer_ui.cc +++ b/atom/browser/ui/webui/pdf_viewer_ui.cc @@ -7,7 +7,6 @@ #include #include "atom/browser/atom_browser_context.h" -#include "atom/browser/stream_manager.h" #include "atom/browser/ui/webui/pdf_viewer_handler.h" #include "atom/common/atom_constants.h" #include "components/pdf/common/pdf_messages.h" @@ -23,6 +22,7 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/resource_context.h" #include "content/public/browser/stream_handle.h" +#include "content/public/browser/stream_info.h" #include "content/public/browser/url_data_source.h" #include "content/public/browser/web_contents.h" #include "grit/pdf_viewer_resources_map.h" diff --git a/filenames.gypi b/filenames.gypi index 1b9e456a55cd..04dfe114e03c 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -280,8 +280,6 @@ 'atom/browser/relauncher.h', 'atom/browser/render_process_preferences.cc', 'atom/browser/render_process_preferences.h', - 'atom/browser/stream_manager.cc', - 'atom/browser/stream_manager.h', 'atom/browser/ui/accelerator_util.cc', 'atom/browser/ui/accelerator_util.h', 'atom/browser/ui/accelerator_util_mac.mm',