StreamManager class is no longer required.

Stream lifetime is managed by webui
This commit is contained in:
deepak1556 2017-02-27 12:44:43 +05:30
parent c982af991d
commit 5a8e522526
7 changed files with 1 additions and 141 deletions

View file

@ -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.

View file

@ -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<AtomPermissionManager> permission_manager_;
std::unique_ptr<AtomBlobReader> blob_reader_;
std::unique_ptr<AtomCTDelegate> ct_delegate_;
std::unique_ptr<StreamManager> stream_manager_;
std::string user_agent_;
bool use_cache_;

View file

@ -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);
}

View file

@ -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<content::StreamInfo> 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<EmbedderObserver>(
this, stream_id, render_process_id, render_frame_id);
}
std::unique_ptr<content::StreamInfo> StreamManager::ReleaseStream(
const std::string& stream_id) {
auto stream = streams_.find(stream_id);
if (stream == streams_.end())
return nullptr;
std::unique_ptr<content::StreamInfo> 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

View file

@ -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 <map>
#include <string>
#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<content::StreamInfo> stream,
const std::string& stream_id,
int render_process_id,
int render_frame_id);
std::unique_ptr<content::StreamInfo> 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<std::string, std::unique_ptr<content::StreamInfo>> streams_;
// StreamID => WebContents Observer.
std::map<std::string, std::unique_ptr<EmbedderObserver>> observers_;
DISALLOW_COPY_AND_ASSIGN(StreamManager);
};
} // namespace atom
#endif // ATOM_BROWSER_STREAM_MANAGER_H_

View file

@ -7,7 +7,6 @@
#include <map>
#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"

View file

@ -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',