From 45491ca7aba545afd0eded3d19c96c4ec16fa774 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 2 Sep 2015 15:16:49 +0800 Subject: [PATCH] Fix API changes --- atom/browser/api/atom_api_content_tracing.cc | 26 +++++++------------ atom/browser/api/atom_api_web_contents.cc | 8 +++--- atom/browser/api/atom_api_web_contents.h | 8 +++--- atom/browser/browser.h | 2 +- atom/browser/native_window.h | 2 +- atom/browser/net/asar/url_request_asar_job.cc | 8 +++--- atom/browser/net/url_request_fetch_job.cc | 2 +- atom/browser/ui/atom_menu_model.h | 2 +- atom/browser/ui/tray_icon.h | 2 +- atom/browser/window_list.cc | 2 +- atom/browser/window_list.h | 3 ++- atom/common/api/atom_api_native_image.cc | 9 ++++--- atom/common/asar/archive.cc | 6 +++-- atom/renderer/atom_renderer_client.cc | 3 +-- atom/renderer/atom_renderer_client.h | 2 +- atom/renderer/guest_view_container.cc | 9 ++++++- atom/renderer/guest_view_container.h | 3 +++ .../pepper_flash_clipboard_message_filter.cc | 19 +++++++------- .../pepper_shared_memory_message_filter.cc | 12 ++------- .../printing/print_web_view_helper.cc | 13 +++++++--- docs/api/content-tracing.md | 14 +++++----- 21 files changed, 81 insertions(+), 74 deletions(-) diff --git a/atom/browser/api/atom_api_content_tracing.cc b/atom/browser/api/atom_api_content_tracing.cc index e404a8f26ca6..e4bf33c7b5c5 100644 --- a/atom/browser/api/atom_api_content_tracing.cc +++ b/atom/browser/api/atom_api_content_tracing.cc @@ -19,27 +19,19 @@ using content::TracingController; namespace mate { template<> -struct Converter { +struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Local val, - base::trace_event::CategoryFilter* out) { - std::string filter; - if (!ConvertFromV8(isolate, val, &filter)) - return false; - *out = base::trace_event::CategoryFilter(filter); - return true; - } -}; - -template<> -struct Converter { - static bool FromV8(v8::Isolate* isolate, - v8::Local val, - base::trace_event::TraceOptions* out) { - std::string options; + base::trace_event::TraceConfig* out) { + Dictionary options; if (!ConvertFromV8(isolate, val, &options)) return false; - return out->SetFromString(options); + std::string category_filter, trace_options; + if (!options.Get("categoryFilter", &category_filter) || + !options.Get("traceOptions", &trace_options)) + return false; + *out = base::trace_event::TraceConfig(category_filter, trace_options); + return true; } }; diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 59a50d5656ce..5b723801cdeb 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -217,7 +217,7 @@ bool WebContents::ShouldCreateWebContents( int route_id, int main_frame_route_id, WindowContainerType window_container_type, - const base::string16& frame_name, + const std::string& frame_name, const GURL& target_url, const std::string& partition_id, content::SessionStorageNamespace* session_storage_namespace) { @@ -362,14 +362,16 @@ void WebContents::DidFailProvisionalLoad( content::RenderFrameHost* render_frame_host, const GURL& validated_url, int error_code, - const base::string16& error_description) { + const base::string16& error_description, + bool was_ignored_by_handler) { Emit("did-fail-load", error_code, error_description); } void WebContents::DidFailLoad(content::RenderFrameHost* render_frame_host, const GURL& validated_url, int error_code, - const base::string16& error_description) { + const base::string16& error_description, + bool was_ignored_by_handler) { Emit("did-fail-load", error_code, error_description); } diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 45027309ea65..e75e88fd703e 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -135,7 +135,7 @@ class WebContents : public mate::TrackableObject, int route_id, int main_frame_route_id, WindowContainerType window_container_type, - const base::string16& frame_name, + const std::string& frame_name, const GURL& target_url, const std::string& partition_id, content::SessionStorageNamespace* session_storage_namespace) override; @@ -170,11 +170,13 @@ class WebContents : public mate::TrackableObject, void DidFailLoad(content::RenderFrameHost* render_frame_host, const GURL& validated_url, int error_code, - const base::string16& error_description) override; + const base::string16& error_description, + bool was_ignored_by_handler) override; void DidFailProvisionalLoad(content::RenderFrameHost* render_frame_host, const GURL& validated_url, int error_code, - const base::string16& error_description) override; + const base::string16& error_description, + bool was_ignored_by_handler) override; void DidStartLoading() override; void DidStopLoading() override; void DidGetResourceResponseStart( diff --git a/atom/browser/browser.h b/atom/browser/browser.h index 3e93c84b077f..dc412cefb046 100644 --- a/atom/browser/browser.h +++ b/atom/browser/browser.h @@ -153,7 +153,7 @@ class Browser : public WindowListObserver { void OnWindowAllClosed() override; // Observers of the browser. - ObserverList observers_; + base::ObserverList observers_; // Whether "ready" event has been emitted. bool is_ready_; diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index b9294d38c931..10889a5ccaf9 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -310,7 +310,7 @@ class NativeWindow : public content::WebContentsObserver, brightray::InspectableWebContents* inspectable_web_contents_; // Observers of this window. - ObserverList observers_; + base::ObserverList observers_; base::WeakPtrFactory weak_factory_; diff --git a/atom/browser/net/asar/url_request_asar_job.cc b/atom/browser/net/asar/url_request_asar_job.cc index de019f6d9420..88195a0d7c79 100644 --- a/atom/browser/net/asar/url_request_asar_job.cc +++ b/atom/browser/net/asar/url_request_asar_job.cc @@ -193,7 +193,7 @@ bool URLRequestAsarJob::IsRedirectResponse(GURL* location, net::Filter* URLRequestAsarJob::SetupFilter() const { // Bug 9936 - .svgz files needs to be decompressed. - return LowerCaseEqualsASCII(file_path_.Extension(), ".svgz") + return base::LowerCaseEqualsASCII(file_path_.Extension(), ".svgz") ? net::Filter::GZipFactory() : NULL; } @@ -265,8 +265,7 @@ void URLRequestAsarJob::DidOpen(int result) { } if (type_ == TYPE_ASAR) { - int rv = stream_->Seek(base::File::FROM_BEGIN, - file_info_.offset, + int rv = stream_->Seek(file_info_.offset, base::Bind(&URLRequestAsarJob::DidSeek, weak_ptr_factory_.GetWeakPtr())); if (rv != net::ERR_IO_PENDING) { @@ -285,8 +284,7 @@ void URLRequestAsarJob::DidOpen(int result) { byte_range_.first_byte_position() + 1; if (remaining_bytes_ > 0 && byte_range_.first_byte_position() != 0) { - int rv = stream_->Seek(base::File::FROM_BEGIN, - byte_range_.first_byte_position(), + int rv = stream_->Seek(byte_range_.first_byte_position(), base::Bind(&URLRequestAsarJob::DidSeek, weak_ptr_factory_.GetWeakPtr())); if (rv != net::ERR_IO_PENDING) { diff --git a/atom/browser/net/url_request_fetch_job.cc b/atom/browser/net/url_request_fetch_job.cc index eacaada19358..a8a16e286b30 100644 --- a/atom/browser/net/url_request_fetch_job.cc +++ b/atom/browser/net/url_request_fetch_job.cc @@ -23,7 +23,7 @@ namespace { // Convert string to RequestType. net::URLFetcher::RequestType GetRequestType(const std::string& raw) { - std::string method = StringToUpperASCII(raw); + std::string method = base::StringToUpperASCII(raw); if (method.empty() || method == "GET") return net::URLFetcher::GET; else if (method == "POST") diff --git a/atom/browser/ui/atom_menu_model.h b/atom/browser/ui/atom_menu_model.h index fe19a8dc2518..d091df9fb570 100644 --- a/atom/browser/ui/atom_menu_model.h +++ b/atom/browser/ui/atom_menu_model.h @@ -43,7 +43,7 @@ class AtomMenuModel : public ui::SimpleMenuModel { Delegate* delegate_; // weak ref. std::map roles_; - ObserverList observers_; + base::ObserverList observers_; DISALLOW_COPY_AND_ASSIGN(AtomMenuModel); }; diff --git a/atom/browser/ui/tray_icon.h b/atom/browser/ui/tray_icon.h index 55f1c41d19d7..af774ddbfb42 100644 --- a/atom/browser/ui/tray_icon.h +++ b/atom/browser/ui/tray_icon.h @@ -67,7 +67,7 @@ class TrayIcon { TrayIcon(); private: - ObserverList observers_; + base::ObserverList observers_; DISALLOW_COPY_AND_ASSIGN(TrayIcon); }; diff --git a/atom/browser/window_list.cc b/atom/browser/window_list.cc index 9a2089e57434..b3bec5d08c1c 100644 --- a/atom/browser/window_list.cc +++ b/atom/browser/window_list.cc @@ -13,7 +13,7 @@ namespace atom { // static -base::LazyInstance>::Leaky +base::LazyInstance>::Leaky WindowList::observers_ = LAZY_INSTANCE_INITIALIZER; // static diff --git a/atom/browser/window_list.h b/atom/browser/window_list.h index 7ba5a7957561..bfb9a2b0aecc 100644 --- a/atom/browser/window_list.h +++ b/atom/browser/window_list.h @@ -60,7 +60,8 @@ class WindowList { // A list of observers which will be notified of every window addition and // removal across all WindowLists. - static base::LazyInstance>::Leaky observers_; + static base::LazyInstance>::Leaky + observers_; static WindowList* instance_; diff --git a/atom/common/api/atom_api_native_image.cc b/atom/common/api/atom_api_native_image.cc index 879c73394293..df6c14dab350 100644 --- a/atom/common/api/atom_api_native_image.cc +++ b/atom/common/api/atom_api_native_image.cc @@ -14,6 +14,7 @@ #include "atom/common/node_includes.h" #include "base/base64.h" #include "base/strings/string_util.h" +#include "base/strings/pattern.h" #include "native_mate/dictionary.h" #include "native_mate/object_template_builder.h" #include "net/base/data_url.h" @@ -62,7 +63,7 @@ float GetScaleFactorFromPath(const base::FilePath& path) { // We don't try to convert string to float here because it is very very // expensive. for (unsigned i = 0; i < arraysize(kScaleFactorPairs); ++i) { - if (EndsWith(filename, kScaleFactorPairs[i].name, true)) + if (base::EndsWith(filename, kScaleFactorPairs[i].name, true)) return kScaleFactorPairs[i].scale; } @@ -104,7 +105,7 @@ bool PopulateImageSkiaRepsFromPath(gfx::ImageSkia* image, const base::FilePath& path) { bool succeed = false; std::string filename(path.BaseName().RemoveExtension().AsUTF8Unsafe()); - if (MatchPattern(filename, "*@*x")) + if (base::MatchPattern(filename, "*@*x")) // Don't search for other representations if the DPI has been specified. return AddImageSkiaRep(image, path, GetScaleFactorFromPath(path)); else @@ -119,8 +120,8 @@ bool PopulateImageSkiaRepsFromPath(gfx::ImageSkia* image, #if defined(OS_MACOSX) bool IsTemplateFilename(const base::FilePath& path) { - return (MatchPattern(path.value(), "*Template.*") || - MatchPattern(path.value(), "*Template@*x.*")); + return (base::MatchPattern(path.value(), "*Template.*") || + base::MatchPattern(path.value(), "*Template@*x.*")); } #endif diff --git a/atom/common/asar/archive.cc b/atom/common/asar/archive.cc index be99530c9c98..0b2f59ae0f18 100644 --- a/atom/common/asar/archive.cc +++ b/atom/common/asar/archive.cc @@ -136,7 +136,8 @@ bool Archive::Init() { } uint32 size; - if (!PickleIterator(Pickle(buf.data(), buf.size())).ReadUInt32(&size)) { + if (!base::PickleIterator(base::Pickle(buf.data(), buf.size())).ReadUInt32( + &size)) { LOG(ERROR) << "Failed to parse header size from " << path_.value(); return false; } @@ -149,7 +150,8 @@ bool Archive::Init() { } std::string header; - if (!PickleIterator(Pickle(buf.data(), buf.size())).ReadString(&header)) { + if (!base::PickleIterator(base::Pickle(buf.data(), buf.size())).ReadString( + &header)) { LOG(ERROR) << "Failed to parse header from " << path_.value(); return false; } diff --git a/atom/renderer/atom_renderer_client.cc b/atom/renderer/atom_renderer_client.cc index e17e8bf3db9b..ef5ac757d9f4 100644 --- a/atom/renderer/atom_renderer_client.cc +++ b/atom/renderer/atom_renderer_client.cc @@ -27,7 +27,6 @@ #include "third_party/WebKit/public/web/WebPluginParams.h" #include "third_party/WebKit/public/web/WebKit.h" #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" -#include "third_party/WebKit/Source/wtf/ArrayBufferContents.h" #include "atom/common/node_includes.h" @@ -205,7 +204,7 @@ void AtomRendererClient::DidCreateScriptContext( node_bindings_->LoadEnvironment(env); } -bool AtomRendererClient::ShouldFork(blink::WebFrame* frame, +bool AtomRendererClient::ShouldFork(blink::WebLocalFrame* frame, const GURL& url, const std::string& http_method, bool is_initial_navigation, diff --git a/atom/renderer/atom_renderer_client.h b/atom/renderer/atom_renderer_client.h index e59547cf8eb1..206ed9f9b9b7 100644 --- a/atom/renderer/atom_renderer_client.h +++ b/atom/renderer/atom_renderer_client.h @@ -45,7 +45,7 @@ class AtomRendererClient : public content::ContentRendererClient, blink::WebLocalFrame* frame, const blink::WebPluginParams& params, blink::WebPlugin** plugin) override; - bool ShouldFork(blink::WebFrame* frame, + bool ShouldFork(blink::WebLocalFrame* frame, const GURL& url, const std::string& http_method, bool is_initial_navigation, diff --git a/atom/renderer/guest_view_container.cc b/atom/renderer/guest_view_container.cc index c0bc1427d68c..f50c3f78685c 100644 --- a/atom/renderer/guest_view_container.cc +++ b/atom/renderer/guest_view_container.cc @@ -6,7 +6,9 @@ #include +#include "base/bind.h" #include "base/lazy_instance.h" +#include "base/message_loop/message_loop.h" #include "ui/gfx/geometry/size.h" namespace atom { @@ -20,7 +22,8 @@ static base::LazyInstance g_guest_view_container_map = } // namespace GuestViewContainer::GuestViewContainer(content::RenderFrame* render_frame) - : render_frame_(render_frame) { + : render_frame_(render_frame), + weak_ptr_factory_(this) { } GuestViewContainer::~GuestViewContainer() { @@ -55,4 +58,8 @@ void GuestViewContainer::DidResizeElement(const gfx::Size& new_size) { FROM_HERE, base::Bind(element_resize_callback_, new_size)); } +base::WeakPtr GuestViewContainer::GetWeakPtr() { + return weak_ptr_factory_.GetWeakPtr(); +} + } // namespace atom diff --git a/atom/renderer/guest_view_container.h b/atom/renderer/guest_view_container.h index 2846265cb2af..3771c7adc4e6 100644 --- a/atom/renderer/guest_view_container.h +++ b/atom/renderer/guest_view_container.h @@ -28,6 +28,7 @@ class GuestViewContainer : public content::BrowserPluginDelegate { // content::BrowserPluginDelegate: void SetElementInstanceID(int element_instance_id) final; void DidResizeElement(const gfx::Size& new_size) final; + base::WeakPtr GetWeakPtr() final; private: int element_instance_id_; @@ -35,6 +36,8 @@ class GuestViewContainer : public content::BrowserPluginDelegate { ResizeCallback element_resize_callback_; + base::WeakPtrFactory weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(GuestViewContainer); }; diff --git a/chromium_src/chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.cc b/chromium_src/chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.cc index 4499b21aefe3..fdc054f59fbd 100644 --- a/chromium_src/chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.cc +++ b/chromium_src/chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.cc @@ -46,7 +46,8 @@ ui::ClipboardType ConvertClipboardType(uint32_t type) { // assume all data that is placed on the clipboard is UTF16 and pepper allows // arbitrary data so this change would require some reworking of the chrome // clipboard interface for custom data. -bool JumpToFormatInPickle(const base::string16& format, PickleIterator* iter) { +bool JumpToFormatInPickle(const base::string16& format, + base::PickleIterator* iter) { size_t size = 0; if (!iter->ReadSizeT(&size)) return false; @@ -66,22 +67,22 @@ bool JumpToFormatInPickle(const base::string16& format, PickleIterator* iter) { } bool IsFormatAvailableInPickle(const base::string16& format, - const Pickle& pickle) { - PickleIterator iter(pickle); + const base::Pickle& pickle) { + base::PickleIterator iter(pickle); return JumpToFormatInPickle(format, &iter); } std::string ReadDataFromPickle(const base::string16& format, - const Pickle& pickle) { + const base::Pickle& pickle) { std::string result; - PickleIterator iter(pickle); + base::PickleIterator iter(pickle); if (!JumpToFormatInPickle(format, &iter) || !iter.ReadString(&result)) return std::string(); return result; } bool WriteDataToPickle(const std::map& data, - Pickle* pickle) { + base::Pickle* pickle) { pickle->WriteSizeT(data.size()); for (std::map::const_iterator it = data.begin(); it != data.end(); @@ -187,7 +188,7 @@ int32_t PepperFlashClipboardMessageFilter::OnMsgIsFormatAvailable( std::string clipboard_data; clipboard->ReadData(ui::Clipboard::GetPepperCustomDataFormatType(), &clipboard_data); - Pickle pickle(clipboard_data.data(), clipboard_data.size()); + base::Pickle pickle(clipboard_data.data(), clipboard_data.size()); available = IsFormatAvailableInPickle(base::UTF8ToUTF16(format_name), pickle); } @@ -265,7 +266,7 @@ int32_t PepperFlashClipboardMessageFilter::OnMsgReadData( std::string clipboard_data; clipboard->ReadData(ui::Clipboard::GetPepperCustomDataFormatType(), &clipboard_data); - Pickle pickle(clipboard_data.data(), clipboard_data.size()); + base::Pickle pickle(clipboard_data.data(), clipboard_data.size()); if (IsFormatAvailableInPickle(format_name, pickle)) { result = PP_OK; clipboard_string = ReadDataFromPickle(format_name, pickle); @@ -340,7 +341,7 @@ int32_t PepperFlashClipboardMessageFilter::OnMsgWriteData( } if (custom_data_map.size() > 0) { - Pickle pickle; + base::Pickle pickle; if (WriteDataToPickle(custom_data_map, &pickle)) { scw.WritePickledData(pickle, ui::Clipboard::GetPepperCustomDataFormatType()); diff --git a/chromium_src/chrome/renderer/pepper/pepper_shared_memory_message_filter.cc b/chromium_src/chrome/renderer/pepper/pepper_shared_memory_message_filter.cc index e01aea741fc8..3ef6dff0c8bc 100644 --- a/chromium_src/chrome/renderer/pepper/pepper_shared_memory_message_filter.cc +++ b/chromium_src/chrome/renderer/pepper/pepper_shared_memory_message_filter.cc @@ -56,17 +56,9 @@ void PepperSharedMemoryMessageFilter::OnHostMsgCreateSharedMemory( ->GetVarTracker() ->TrackSharedMemoryHandle(instance, host_shm_handle, size); - base::PlatformFile host_handle = -#if defined(OS_WIN) - host_shm_handle; -#elif defined(OS_POSIX) - host_shm_handle.fd; -#else -#error Not implemented. -#endif // We set auto_close to false since we need our file descriptor to // actually be duplicated on linux. The shared memory destructor will // close the original handle for us. - plugin_handle->set_shmem(host_->ShareHandleWithRemote(host_handle, false), - size); + plugin_handle->set_shmem( + host_->ShareSharedMemoryHandleWithRemote(host_shm_handle), size); } diff --git a/chromium_src/chrome/renderer/printing/print_web_view_helper.cc b/chromium_src/chrome/renderer/printing/print_web_view_helper.cc index cba75b651b6b..20ac1fdc9b4f 100644 --- a/chromium_src/chrome/renderer/printing/print_web_view_helper.cc +++ b/chromium_src/chrome/renderer/printing/print_web_view_helper.cc @@ -427,9 +427,10 @@ class PrepareFrameAndViewForPrint : public blink::WebViewClient, // blink::WebFrameClient override: virtual blink::WebFrame* createChildFrame( blink::WebLocalFrame* parent, + blink::WebTreeScopeType scope, const blink::WebString& name, blink::WebSandboxFlags sandboxFlags); - virtual void frameDetached(blink::WebFrame* frame); + virtual void frameDetached(blink::WebFrame* frame, DetachType type); private: void CallOnReady(); @@ -548,7 +549,8 @@ void PrepareFrameAndViewForPrint::CopySelection( blink::WebView* web_view = blink::WebView::create(this); owns_web_view_ = true; content::RenderView::ApplyWebPreferences(prefs, web_view); - web_view->setMainFrame(blink::WebLocalFrame::create(this)); + web_view->setMainFrame( + blink::WebLocalFrame::create(blink::WebTreeScopeType::Document, this)); frame_.Reset(web_view->mainFrame()->toWebLocalFrame()); node_to_print_.reset(); @@ -573,14 +575,17 @@ void PrepareFrameAndViewForPrint::didStopLoading() { blink::WebFrame* PrepareFrameAndViewForPrint::createChildFrame( blink::WebLocalFrame* parent, + blink::WebTreeScopeType scope, const blink::WebString& name, blink::WebSandboxFlags sandboxFlags) { - blink::WebFrame* frame = blink::WebLocalFrame::create(this); + blink::WebFrame* frame = blink::WebLocalFrame::create(scope, this); parent->appendChild(frame); return frame; } -void PrepareFrameAndViewForPrint::frameDetached(blink::WebFrame* frame) { +void PrepareFrameAndViewForPrint::frameDetached(blink::WebFrame* frame, + DetachType type) { + DCHECK(type == DetachType::Remove); if (frame->parent()) frame->parent()->removeChild(frame); frame->close(); diff --git a/docs/api/content-tracing.md b/docs/api/content-tracing.md index 9161f5f362a1..2e05fc67668f 100644 --- a/docs/api/content-tracing.md +++ b/docs/api/content-tracing.md @@ -33,10 +33,11 @@ are reached. Once all child processes have acknowledged the `getCategories` request the `callback` is invoked with an array of category groups. -### `contentTracing.startRecording(categoryFilter, traceOptions, callback)` +### `contentTracing.startRecording(options, callback)` -* `categoryFilter` String -* `traceOptions` String +* `options` Object + * `categoryFilter` String + * `traceOptions` String * `callback` Function Start recording on all processes. @@ -94,10 +95,11 @@ Trace data will be written into `resultFilePath` if it is not empty or into a temporary file. The actual file path will be passed to `callback` if it's not `null`. -### `contentTracing.startMonitoring(categoryFilter, traceOptions, callback)` +### `contentTracing.startMonitoring(options, callback)` -* `categoryFilter` String -* `traceOptions` String +* `options` Object + * `categoryFilter` String + * `traceOptions` String * `callback` Function Start monitoring on all processes.