Commit dd5e80b2 authored by shrikant's avatar shrikant Committed by Commit bot

Adding more checking and some debugging information in Custom Font Collection.

+rsesek for crash key/value OWNERS.

R=scottmg,ananta,cpu
TBR=rsesek@chromium.org
BUG=399233

Review URL: https://codereview.chromium.org/508393002

Cr-Commit-Position: refs/heads/master@{#292292}
parent 5814471f
...@@ -61,6 +61,8 @@ const char kChannel[] = "channel"; ...@@ -61,6 +61,8 @@ const char kChannel[] = "channel";
const char kActiveURL[] = "url-chunk"; const char kActiveURL[] = "url-chunk";
const char kFontKeyName[] = "font_key_name";
const char kSwitch[] = "switch-%" PRIuS; const char kSwitch[] = "switch-%" PRIuS;
const char kNumSwitches[] = "num-switches"; const char kNumSwitches[] = "num-switches";
...@@ -144,6 +146,7 @@ size_t RegisterChromeCrashKeys() { ...@@ -144,6 +146,7 @@ size_t RegisterChromeCrashKeys() {
// base/: // base/:
{ "dm-usage", kSmallSize }, { "dm-usage", kSmallSize },
// content/: // content/:
{ kFontKeyName, kSmallSize},
{ "ppapi_path", kMediumSize }, { "ppapi_path", kMediumSize },
{ "subresource_url", kLargeSize }, { "subresource_url", kLargeSize },
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
......
...@@ -11,12 +11,14 @@ ...@@ -11,12 +11,14 @@
#include <wrl/wrappers/corewrappers.h> #include <wrl/wrappers/corewrappers.h>
#include "base/debug/alias.h" #include "base/debug/alias.h"
#include "base/debug/crash_logging.h"
#include "base/files/file_enumerator.h" #include "base/files/file_enumerator.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/files/memory_mapped_file.h" #include "base/files/memory_mapped_file.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h" #include "base/memory/scoped_vector.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "base/win/iat_patch_function.h" #include "base/win/iat_patch_function.h"
#include "base/win/registry.h" #include "base/win/registry.h"
...@@ -27,6 +29,8 @@ namespace { ...@@ -27,6 +29,8 @@ namespace {
namespace mswr = Microsoft::WRL; namespace mswr = Microsoft::WRL;
namespace mswrw = Microsoft::WRL::Wrappers; namespace mswrw = Microsoft::WRL::Wrappers;
static const char kFontKeyName[] = "font_key_name";
class FontCollectionLoader class FontCollectionLoader
: public mswr::RuntimeClass<mswr::RuntimeClassFlags<mswr::ClassicCom>, : public mswr::RuntimeClass<mswr::RuntimeClassFlags<mswr::ClassicCom>,
IDWriteFontCollectionLoader> { IDWriteFontCollectionLoader> {
...@@ -67,7 +71,9 @@ class FontFileStream ...@@ -67,7 +71,9 @@ class FontFileStream
UINT64 file_offset, UINT64 file_offset,
UINT64 fragment_size, UINT64 fragment_size,
void** context) { void** context) {
if (!memory_.get() || !memory_->IsValid()) if (!memory_.get() || !memory_->IsValid() ||
file_offset >= memory_->length() ||
(file_offset + fragment_size) > memory_->length())
return E_FAIL; return E_FAIL;
*fragment_start = static_cast<BYTE const*>(memory_->data()) + *fragment_start = static_cast<BYTE const*>(memory_->data()) +
...@@ -106,7 +112,8 @@ class FontFileStream ...@@ -106,7 +112,8 @@ class FontFileStream
HRESULT RuntimeClassInitialize(UINT32 font_key) { HRESULT RuntimeClassInitialize(UINT32 font_key) {
base::FilePath path; base::FilePath path;
PathService::Get(base::DIR_WINDOWS_FONTS, &path); PathService::Get(base::DIR_WINDOWS_FONTS, &path);
path = path.Append(g_font_loader->GetFontNameFromKey(font_key).c_str()); std::wstring font_key_name(g_font_loader->GetFontNameFromKey(font_key));
path = path.Append(font_key_name.c_str());
memory_.reset(new base::MemoryMappedFile()); memory_.reset(new base::MemoryMappedFile());
// Put some debug information on stack. // Put some debug information on stack.
...@@ -120,6 +127,9 @@ class FontFileStream ...@@ -120,6 +127,9 @@ class FontFileStream
} }
font_key_ = font_key; font_key_ = font_key;
base::debug::SetCrashKeyValue(kFontKeyName,
base::WideToUTF8(font_key_name));
return S_OK; return S_OK;
} }
...@@ -299,6 +309,8 @@ IDWriteFontCollection* GetCustomFontCollection(IDWriteFactory* factory) { ...@@ -299,6 +309,8 @@ IDWriteFontCollection* GetCustomFontCollection(IDWriteFactory* factory) {
CHECK(SUCCEEDED(hr)); CHECK(SUCCEEDED(hr));
CHECK(g_font_collection.Get() != NULL); CHECK(g_font_collection.Get() != NULL);
base::debug::ClearCrashKey(kFontKeyName);
return g_font_collection.Get(); return g_font_collection.Get();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment