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

Side by Side Diff: chrome/renderer/chrome_render_view_observer.cc

Issue 296593003: Make various string_util functions take StringPieces instead of char[]. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Resync Created 6 years, 6 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
« no previous file with comments | « chrome/installer/util/shell_util.cc ('k') | chromeos/system/name_value_pairs_parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/renderer/chrome_render_view_observer.h" 5 #include "chrome/renderer/chrome_render_view_observer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 sprintf_s(buf, "%d chars retrieved for indexing in %gms\n", 562 sprintf_s(buf, "%d chars retrieved for indexing in %gms\n",
563 contents.size(), (end - begin)*1000); 563 contents.size(), (end - begin)*1000);
564 OutputDebugStringA(buf); 564 OutputDebugStringA(buf);
565 #endif 565 #endif
566 566
567 // When the contents are clipped to the maximum, we don't want to have a 567 // When the contents are clipped to the maximum, we don't want to have a
568 // partial word indexed at the end that might have been clipped. Therefore, 568 // partial word indexed at the end that might have been clipped. Therefore,
569 // terminate the string at the last space to ensure no words are clipped. 569 // terminate the string at the last space to ensure no words are clipped.
570 if (contents->size() == kMaxIndexChars) { 570 if (contents->size() == kMaxIndexChars) {
571 size_t last_space_index = contents->find_last_of(base::kWhitespaceUTF16); 571 size_t last_space_index = contents->find_last_of(base::kWhitespaceUTF16);
572 if (last_space_index == base::string16::npos) 572 if (last_space_index != base::string16::npos)
573 return; // don't index if we got a huge block of text with no spaces 573 contents->resize(last_space_index);
574 contents->resize(last_space_index);
575 } 574 }
576 } 575 }
577 576
578 bool ChromeRenderViewObserver::HasRefreshMetaTag(WebFrame* frame) { 577 bool ChromeRenderViewObserver::HasRefreshMetaTag(WebFrame* frame) {
579 if (!frame) 578 if (!frame)
580 return false; 579 return false;
581 WebElement head = frame->document().head(); 580 WebElement head = frame->document().head();
582 if (head.isNull() || !head.hasChildNodes()) 581 if (head.isNull() || !head.hasChildNodes())
583 return false; 582 return false;
584 583
585 const WebString tag_name(base::ASCIIToUTF16("meta")); 584 const WebString tag_name(base::ASCIIToUTF16("meta"));
586 const WebString attribute_name(base::ASCIIToUTF16("http-equiv")); 585 const WebString attribute_name(base::ASCIIToUTF16("http-equiv"));
587 586
588 WebNodeList children = head.childNodes(); 587 WebNodeList children = head.childNodes();
589 for (size_t i = 0; i < children.length(); ++i) { 588 for (size_t i = 0; i < children.length(); ++i) {
590 WebNode node = children.item(i); 589 WebNode node = children.item(i);
591 if (!node.isElementNode()) 590 if (!node.isElementNode())
592 continue; 591 continue;
593 WebElement element = node.to<WebElement>(); 592 WebElement element = node.to<WebElement>();
594 if (!element.hasTagName(tag_name)) 593 if (!element.hasTagName(tag_name))
595 continue; 594 continue;
596 WebString value = element.getAttribute(attribute_name); 595 WebString value = element.getAttribute(attribute_name);
597 if (value.isNull() || !LowerCaseEqualsASCII(value, "refresh")) 596 if (value.isNull() || !LowerCaseEqualsASCII(value, "refresh"))
598 continue; 597 continue;
599 return true; 598 return true;
600 } 599 }
601 return false; 600 return false;
602 } 601 }
OLDNEW
« no previous file with comments | « chrome/installer/util/shell_util.cc ('k') | chromeos/system/name_value_pairs_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698